When I try to use the save()
method of eloquent-laravel 5.1, in the way it asks for documentation, the update is not done in the database.
This is how the documentation asks for it:
$flight = App\Flight::find(1);
$flight->name = 'New Flight Name';
$flight->save();
This is mine:
public function adotado($id) {
$animal = Animal::find($id);
if (Auth::user()->id == $animal->user_id) {
$animal->ativo = 0;
$animal->save();
return redirect()->action('UserController@index');
} else {
return view('errors.restrito');
}
}
I checked with dd($animal)
that data is being pulled normally from the database after find()
, even the 'active' attribute is equal to 1. Within if
, dd($animal->ativo)
returns 0, ie up there the code is ok. The dd($animal->save())
also returns true and is normally redirected to the index, however, the update does not appear in db.
Any tips? Save me who can. Thankful.