Home Ask Login Register

Developers Planet

Your answer is one click away!

danjswade February 2016

Update Table Using Laravel Model

I've got a table for a sports team. The record shows the team selection and some other information. I want to update the record with the team selection. My model is thus:

class Selection extends Model {

protected $table = "selection";

protected $fillable = [


So I have a form which gives all the data for the positions and gives the id for the record in the DB. In my controller, I've got:

public function storeFirstTeam()
    $input = Request::all();


    return redirect('first-team');

But I get the following error:

Non-static method Illuminate\Database\Eloquent\Model::update() should not be called statically, assuming $this from incompatible context

Can anyone point out my silly error?


The Alpha February 2016

You should write it like given example below:

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

Alternatively, you may write it like this as well:


Martin Bean February 2016

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:


Jilson Thomas February 2016

Check my comment and this would solve the problem:


Post Status

Asked in February 2016
Viewed 3,264 times
Voted 10
Answered 3 times


Leave an answer

Quote of the day: live life