3
When I try to use the method save()
eloquent-Variable 5.1, in the manner requesting the documentation, the update is not made in the bank.
This is how you ask for documentation:
$flight = App\Flight::find(1);
$flight->name = 'New Flight Name';
$flight->save();
This is my:
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 the data is normally being pulled from the database after the find()
, including the active attribute is 1. Inside the if
, dd($animal->ativo)
returns 0, that is, until then the code is ok. The dd($animal->save())
also returns true and is redirected normally to index, however the update does not appear in db.
Any tips? Save me as many as you can. Thank you.
Try commenting on redirect and check if there are any errors
– gmsantos
No mistake. =\
– Jonatas Lima
Checks the return of
save
, may be returningfalse
. Would be the methodpush
useful in that case?– Woss
@Virgilionovic the change is being made in the active $animal->that is 1 in db. After I set active = 0 within the if, return of dd($animal->active) was 0, then had change.
– Jonatas Lima
@Andersoncarloswoss the return of save() is 1. I tried to push as well and continued in it.
– Jonatas Lima