nnnayeem
11 months ago
120
15
Laravel

laravel is trying to update _method field

Posted 11 months ago by nnnayeem

Hello everyone,

One my project I am trying to update some data but getting this error

    SQLSTATE[42S22]: Column not found: 1054 Unknown column '_method' in 'field list' (SQL: update `vendors` set `_method` = PATCH, `_token` = LTWtWQjXpMd5Pi6xQdn2oS6PuaPovsKLP6Sz7M00, `name` = a, `phone` = 2323, `fatherName` = a, `motherName` = a, `gender` = male, `birthDate` = 2018-10-31, `permanentAdd` = a, `altPhone` = 121212, `nomineeName` = a, `nomineePhone` = 121212, `nomineeRelation` = Sister, `updated_at` = 2018-10-19 06:13:35 where `vendors`.`user_id` = 103 and `vendors`.`user_id` is not null)

My route:

Route::patch('profile/{id}/update','[email protected]');

My Controller:

        public function UpdateProfile(Request $request,$id){
    if(Auth::user()->id == $id){
        $data = $request->all();
        $rules = [
            'name'=>'required|max:100',
            'phone'=>'required|max:100',
            'fatherName'=>'required|max:100',
            'motherName'=>'required|max:100',
            'gender'=>'required|max:100',
            'birthDate'=>'required|max:100',
            'permanentAdd'=>'required|max:100',
            'altPhone'=>'required|max:100',
            'nomineeName'=>'required|max:100',
            'nomineePhone'=>'required|max:100',
            'nomineeRelation'=>'required|max:100',
        ];
        $message = [
            'name.required'=>'name re',
        ];
        Validator::make($data,$rules,$message)->validate();
        $user = User::findOrFail($id);
        $user->update($data);
        $user->vendor()->update($data);
        return redirect('/vendor-profile');
    }else{
        abort(404);
    }

}

I have searched solution for this problem onine. The are all telling to except the _method and _token method. Some saying to use $fillable property.

But I have already used $fillable property and also updated model in the above mentioned way. I just cant figure out what the problem is?

Please sign in or create an account to participate in this conversation.