Laravel Eloquent - $fillable is not working? -


i have set variable $fillable in model. wanted test update functionality, , error:

sqlstate[42s22]: column not found: 1054 unknown column '_method' in 'field list' (sql: update positions set name = casual aquatic leader, _method = put, id = 2, description = here description, updated_at = 2014-05-29 17:05:11 positions.client_id = 1 , id = 2)"

why yelling @ _method when fillable doesn't have parameter? update function is:

client::find($client_id)         ->positions()         ->whereid($id)         ->update(input::all()); 

change following:

->update(input::all()); 

to (exclude _method array)

->update(input::except('_method')); 

update:

actually following update method being called illuminate\database\eloquent\builder class being triggered _call method of illuminate\database\eloquent\relations class (because calling update on relation) , hence $fillable check not getting performed , may use input::except('_method') answered:

public function update(array $values) {     return $this->query->update($this->addupdatedatcolumn($values)); } 

if directly call on model (not on relation):

positions::find($id)->update(input::all()); 

then not happen because fillable check performed within model.php because following update method called illuminate\database\eloquent\model class:

public function update(array $attributes = array()) {     if ( ! $this->exists)     {         return $this->newquery()->update($attributes);     }      return $this->fill($attributes)->save(); } 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -