Answer the question
In order to leave comments, you need to log in
Laravel asynchronous work, what am I doing wrong?
There is a certain list of tasks that hung on the crown and run commands:
foreach ($Sites as $site) {
$EveryMethod = $site->frequency_of_removal;
$schedule
->command(RemoverPositions::class, [$site->id])
->cron($EveryMethod);
}
SiteRemoverPositions::dispatch($Site)->onQueue($Site->name);
<?php
namespace App\Jobs;
use App\Console\Commands\RemovalPositions;
use App\Helpers\RemovalSiteHelper;
use App\Site;
use App\Test;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SiteRemoverPositions implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private $site;
/**
* Create a new job instance.
*
* @param Site $site
*/
public function __construct(Site $site)
{
(new Test(["value" => "constructor job"]))->save();
$this->site = $site;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
(new Test(["value" => "handle job"]))->save();
$Site = $this->site;
(new RemovalSiteHelper($Site))
->removal();
}
}
Answer the question
In order to leave comments, you need to log in
The worker himself gets into the queue with the specified name in the database, but what to do with him next ??
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question