Hello Guys!
I have some problems with the usage of Events and Listeners. I'm trying to make an Audit Log for my site and I tried to be elegant and use Events, but I ran into some interesting behaviour when passing an Eloquent object to the event.
For example I want to log that a Scope was deleted from the table (since I need to write some logic the Log:: is not an option)
$scope->delete(); event(new DatabaseModified($scope));
In the event I simply pass the Eloquent object
public function __construct($entry) { $this->entry = $entry; }
But after it I get 404 with No query results for model [App\Entities\Scope]. message.
I tested this and instead of passing the object the listener re-queries the DB and use the new object.
Why does this works like that?
What are my options for possible workaround?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community