I have a Manifestation
template that uses SoftDeletingTrait
to keep them inactive in the database and in ManifestationController
I have the following destroy()
method:
$manifestation = Manifestation::findOrFail($id);
$manifestation->closedBy()->associate(Auth::user());
$manifestation->save(); // save para marcar o usuário que encerrou
$manifestation->delete();
And if right after $manifestation->trashed()
, it returns true
, and so far everything is correct. However, I also have a method restore()
in controller
, with the following:
$manifestation = Manifestation::withTrashed()->findOrFail($id);
$manifestation->closed_by_id = null;
$manifestation->save();
$manifestation->restore();
The problem is that if I use $manifestation->trashed()
this time, I keep getting true
as a result, even though the model is no longer inactive.
trashed()
to return false
after restore()
? If I'm not mistaken, there must be flag
, as well as exists
of class Eloquent
that can possibly be changed, but I could not find it. I could, instead of using trashed
, check that the deleted_at
value is null , but I want to avoid doing so, unless it is the last opcion.
Notes :
- It returns to normal search results.
- I'm using
Laravel 4.2
and I can not change.