本文整理汇总了PHP中app\Location::user方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::user方法的具体用法?PHP Location::user怎么用?PHP Location::user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Location
的用法示例。
在下文中一共展示了Location::user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
function add(Request $request)
{
$this->validate($request, ['address_name' => 'required', 'postalCode_name' => 'required', 'city_name' => 'required', 'province_name' => 'required', 'country_name' => 'required']);
$json_raw = Input::get('maps_json_name');
$json_obj = json_decode($json_raw);
$city = '';
$country = '';
$province = '';
$street_num = '';
$street_name = '';
$postal_code = '';
$lat = $json_obj[0]->geometry->location->lat;
$lng = $json_obj[0]->geometry->location->lng;
foreach ($json_obj[0]->address_components as $comp) {
switch ($comp->types[0]) {
case 'street_number':
//STREET NUMBER
$street_num = $comp->long_name;
break;
case 'route':
//STREET NAME
$street_name = $comp->long_name;
break;
case 'administrative_area_level_1':
//STATE/PROVINCE
$province = $comp->short_name;
break;
case 'postal_code':
//POSTAL CODE
$postal_code = $comp->long_name;
break;
case 'country':
//COUNTRY
$country = $comp->long_name;
break;
case 'neighborhood':
case 'locality':
$city = $comp->long_name;
break;
}
}
if ($city == '' | $country == '' | $province == '' | $street_name == '' | $street_num == '' | $postal_code == '') {
return redirect('addProperty')->withErrors(["We can't find your full address, please update your info and resubmit"]);
}
$property = new Location();
$property->user()->associate(Auth::user());
$property->street_address = $street_num . " " . $street_name;
$property->postal_code = $postal_code;
$property->province = $province;
$property->country = $country;
$property->longitude = $lng;
$property->latitude = $lat;
$property->city = $city;
// $property->image_path = $filename;
$property->save();
return redirect('profileProperties');
}