In my model
DocumentFieldContent, I have defined below events:
protected $dispatchesEvents = [ 'created' => DocumentFieldCreated::class, //Once document has been uploaded. 'updated' => DocumentFieldUpdated::class, //One the document fields has been updated. ];
Now, when a new
DocumentFieldContent is created in my database, the
event is successfully fired, and the listener is picking up the event just fine.
updated event does not work.
Let's say I update the field manually like:
$update = DocumentFieldContent::find(1); $update->content = 'Updated Content'; $update->save();
App\Events\DocumentFieldUpdated is successfully fired, but the listener is not being "catched":
Name Listeners App\Events\DocumentFieldUpdated 0
I have mapped the necessary things within
protected $listen = [ DocumentFieldCreated::class => [ PerformOCROnDocument::class, ], DocumentFieldUpdated::class => [ ParseDocumentFields::class, ] ];
What I have tried:
I have tried to run below artisan commands:
composer dumpautoload php artisan clear-compiled php artisan queue:restart
But it still does not work when I update the resource.
.env file looks like:
But nothing is added to my database either.
What am I doing wrong?