bacemail
bacemail

Reputation: 129

Laravel 4 update table with array of records

Just filled table with an array of records using:

Floorplan::insert($floorplanMappedArray);    

Tried updating the table by simply swapping "insert" with "update":

Floorplan::update($floorplanMappedArray);    

Error message I'm receiving:

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

What am I missing?

Upvotes: 0

Views: 897

Answers (1)

BMN
BMN

Reputation: 8508

The error message is pretty self-explanatory.

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

You can't call a method like Class::method() if the method is not declared as static.

You have two possibilities :

Declare the method as static or create an instance of Floorplan :

Class Floorplan {
    public static function update() {
        // code goes here
    }
}

Floorplan::update();

Or :

Class Floorplan {
    public function update() {
        // code goes here
    }
}

$floorPlan = new Floorplan();
$floorPlan->update();

Upvotes: 1

Related Questions