Closed aon4o closed 3 months ago
I'm not particularly sure why the problem happens, to be honest.
I tried updating the package's event code to use the SerializesModels
trait and my code started working.
I also tried reproducing it in a Vanilla Laravel installation and couldn't do it. This may be because the User model in my original project is too complex. It utilizes 10 different traits, attribute functions, scopes, and many more.
But I found this in the Laravel 11 docs: Events - Defining Events Queue - Class Structure
These two paragraphs in the documentation make me believe it won't be bad for the package's events to start using the SerializesModels
trait.
PHP & Platform
8.3.6 - Linux Mint 21.3 Cinnamon x64
Database
MySQL 8.0.32
Laravel version
11.7.0
Have you done this?
Expectation
Your package has several events. When I write an event Listener for those, I expect to be able to run the Listeners in a queue like this:
In the example code, the
ShouldQueue
interface and theInteractsWithQueue
trait make the listener execute in a queue.Description
The problem is that the package events don't use the
SerializesModels
trait which leads to the following problem:Serialization of 'Closure' is not allowed
.Reproduction
Stack trace & logs