oliverbusk
5 months ago

Queue - "Updated" doesn't work

Posted 5 months ago by oliverbusk

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.

However, the updated event does not work.

Let's say I update the field manually like:

    $update = DocumentFieldContent::find(1);
    $update->content = 'Updated Content';
    $update->save();

The event 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 EventServiceProvider:

    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.

My .env file looks like:

QUEUE_CONNECTION=database

But nothing is added to my database either.

What am I doing wrong?

Please sign in or create an account to participate in this conversation.