Closed sburkett closed 5 years ago
I'm going to try setting it up as an observer instead, just to see if it matters.
Blah, Observers can't be queueable, so that won't work for me. Ugh.
OMG ... never mind, I am so stupid. The deleted
event occurs after the model has been deleted from the database. So obviously storing that event information serialized in a job won't work, since the id
of the record is now longer there. Ok, closing this issue out, but hopefully it will help someone else one day :)
So I have a parent class
Listing
and a child class ofEbayListing
. The parent class has theHasChildren
trait, and theEbayListing
class has theHasParent
trait.Parent
Listing
class:Child
EbayListing
class:I wanted to set up a few model events to catch certain actions when they happen. Ok, cool, so I added this to the parent
Listing
class:So I set up a test model event for 'deleted'. I made the event listener queueable as I wanted to test some things in the job queue. Now, the queuable delete job I'm queueing doesn't do anything, but I wanted to test things out to make sure I had the queue set up correctly.
So I used
artisan
to do find aListing
and invoke thedelete()
method on it:So good, so far. It added the job to the
jobs
table, which is great, of course. However, the job failed when the artisan queue worker ran (which I thought was odd because thehandle()
method is empty. So I took a look at thefailed_jobs
table and saw that I got a good ol'ModelNotFoundException
:So, I thought, perhaps the
$dispatchesEvents
needed to be in the child class instead of the parent, so I set that all up, but I got the same result.Not really sure why it is complaining, though, as
App\Marketplaces\Ebay\EbayListing
is a valid model, though maybe it needs a backslash in front of theApp
in the class path. Not sure.Any ideas?