Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel 5.2未定义索引:纬度_Php_Mysql_Laravel 5.2 - Fatal编程技术网

Php Laravel 5.2未定义索引:纬度

Php Laravel 5.2未定义索引:纬度,php,mysql,laravel-5.2,Php,Mysql,Laravel 5.2,您好,为什么我有这个选项: 这是控制器: public function addnew(Request $request) { $data = \Input::except(array('_token')) ; $rule=array( 'restaurant_type' => 'required', 'restaurant_name' => 'required', 'restaurant

您好,为什么我有这个选项:

这是控制器:

public function addnew(Request $request)
{ 

    $data =  \Input::except(array('_token')) ;

    $rule=array(
            'restaurant_type' => 'required',
            'restaurant_name' => 'required',
            'restaurant_address' => 'required',
            'restaurant_logo' => 'mimes:jpg,jpeg,gif,png'                
             );

     $validator = \Validator::make($data,$rule);

    if ($validator->fails())
    {
            return redirect()->back()->withErrors($validator->messages());
    }
    $inputs = $request->all();

    if(!empty($inputs['id'])){

        $restaurant_obj = Restaurants::findOrFail($inputs['id']);

    }else{

        $restaurant_obj = new Restaurants;

    }


    //Slug

    if($inputs['restaurant_slug']=="")
    {
        $restaurant_slug = str_slug($inputs['restaurant_name'], "-");
    }
    else
    {
        $restaurant_slug =str_slug($inputs['restaurant_slug'], "-"); 
    }

    //Logo image
    $restaurant_logo = $request->file('restaurant_logo');

    if($restaurant_logo){

         \File::delete(public_path() .'/upload/restaurants/'.$restaurant_obj->restaurant_logo.'-b.jpg');
        \File::delete(public_path() .'/upload/restaurants/'.$restaurant_obj->restaurant_logo.'-s.jpg');

        $tmpFilePath = 'upload/restaurants/';          

        $hardPath = substr($restaurant_slug,0,100).'_'.time();

        $img = Image::make($restaurant_logo);

        $img->fit(120, 120)->save($tmpFilePath.$hardPath.'-b.jpg');
        $img->fit(98, 98)->save($tmpFilePath.$hardPath. '-s.jpg');

        $restaurant_obj->restaurant_logo = $hardPath;

    }

    $user_id=Auth::User()->id;

    $restaurant_obj->user_id = $user_id;
    $restaurant_obj->restaurant_type = $inputs['restaurant_type'];
    $restaurant_obj->restaurant_name = $inputs['restaurant_name']; 
    $restaurant_obj->restaurant_slug = $restaurant_slug;
    $address = $restaurant_obj->restaurant_address = $inputs['restaurant_address'];
    $restaurant_obj->restaurant_description = $inputs['restaurant_description'];

    //ne radi??
    $getGeoCode = Geocode::make()->address($address);

    if($getGeoCode){

        $latitude = $getGeoCode->latitude();
        $longitude = $getGeoCode->longitude();

        $restaurant_obj->latitude = $inputs['latitude'];
        $restaurant_obj->longitude = $inputs['longitude'];

    }

    $restaurant_obj->open_monday = $inputs['open_monday'];
    $restaurant_obj->open_tuesday = $inputs['open_tuesday'];
    $restaurant_obj->open_wednesday = $inputs['open_wednesday'];
    $restaurant_obj->open_thursday = $inputs['open_thursday'];
    $restaurant_obj->open_friday = $inputs['open_friday'];
    $restaurant_obj->open_saturday = $inputs['open_saturday'];
    $restaurant_obj->open_sunday = $inputs['open_sunday']; 



    $restaurant_obj->save();

    if(!empty($inputs['id'])){

        \Session::flash('flash_message', 'Changes Saved');

        return \Redirect::back();
    }else{

        \Session::flash('flash_message', 'Added');

        return \Redirect::back();

    }            


}    
这是一个模型:

    class Restaurants extends Model
{
    protected $table = 'restaurants';

    protected $fillable = ['type', 'restaurant_name','restaurant_slug','restaurant_description','restaurant_address','delivery_charge','restaurant_logo', 'latitude', 'longitude'];


    public $timestamps = false;

    public function restaurants()
    {
        return $this->hasMany('App\Restaurants', 'id');
    }

    public static function getRestaurantsInfo($id) 
    { 
        return Restaurants::find($id);
    }

    public static function getUserRestaurant($id) 
    { 
        return Restaurants::where('user_id',$id)->count(); 
    }


    public static function getMenuCategories($id) 
    { 
        return Categories::where('restaurant_id',$id)->count(); 
    }

    public static function getMenuItems($id) 
    { 
        return Menu::where('restaurant_id',$id)->count(); 
    }

    public static function getOrders($id) 
    { 
        return Order::where('restaurant_id',$id)->count(); 
    }

    public static function getTotalRestaurants() 
    { 
        return Restaurants::count(); 
    } 


    public function scopeSearchByKeyword($query, $keyword)
    {
        if ($keyword!='') {
            $query->where(function ($query) use ($keyword) {
                $query->where("restaurant_address", "LIKE","%$keyword%")
                    ->orWhere("restaurant_name", "LIKE", "%$keyword%");                     
            });
        }
        return $query;
    }

    public static function getRestaurantOwnerInfo() 
    { 
        $rest=Restaurants::find($id);

        return User::find($rest->user_id);
    }

}

我尝试了所有能记住composer dump autoload、php artisan migrate:rollback和make migration等的方法。我的db纬度和经度中都有字段。谢谢。

您似乎想通过发布的代码执行以下操作:

if($getGeoCode){

    $restaurant_obj->latitude = $getGeoCode->latitude();
    $restaurant_obj->longitude = $getGeoCode->longitude();

}

$inputs['LATIONE']不存在。将latitude添加到规则验证中以使sur或do ddInput:all确保$inputs['LATIONE']存在

查看它,我会说这是因为LATIONE不在$inputs数组中。