Update Table Using Laravel Model Update Table Using Laravel Model laravel laravel

Update Table Using Laravel Model


Please check the code below and this would solve your problem:

Selection::whereId($id)->update($request->all());


The error message tells you everything you know: you’re trying to call a method statically (using the double colons) that isn’t meant to be.

The update() method is meant to be called on a model instance, so first you need to retrieve one:

$selection = Selection::find($id);

You can then can the update() method on that:

$selection->update($request->all());


You should write it like given example below:

Selection::where('id', $input['id'])->update($input);// Or use this using dynamic whereSelection::whereId($input['id'])->update($input);

Alternatively, you may write it like this as well:

Selection::find($input['id'])->fill($input)->save();