requests = $requests; $this->title = $title; $this->content = $content; $this->send_mail = $send_mail; } /** * Execute the job. * * @return void */ public function handle(): void { $notificationController = new NotificationController(); $users = $notificationController->query($this->requests); // chunk $users->chunk(100, function ($users) { foreach ($users as $user) { $user->notify(new UserNotification($this->title, $this->content, $this->send_mail)); } }); } }