Level 33
Yup, had this problem before it's not possible.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I tried to dispatch job for my app but its giving me errors
Serialization of 'Closure' is not allowed
here is my in controller
dispatch(new AuthSendMessage($students,$r,$user));
and my AuthSendMessage
class AuthSendMessage implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $students;
protected $r;
protected $user;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($students,$r,$user)
{
$this->students = $students;
$this->r = $r;
$this->user = $user;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
foreach ($this->students as $student)
{
$data = [
'student_id' => $student->id ,
'teacher_id' => null,
'by_owner_id' => Auth::id(),
'by_teacher_id' => null,
'message' => $this->r->message
];
$numbers[] = $student->emer_no;
$this->user->messages()->create($data);
}
}
Please or to participate in this conversation.