QUEUE_DRIVER=database
olarak değiştir.php artisan queue:table
php artisan make:job CompanyCloneJob
<?php
namespace App\Jobs\Company;
use App\Company;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
class CompanyCloneJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private Company $parent;
private Company $child;
/**
* Create a new job instance.
*/
public function __construct(Company $parent, Company $child)
{
//
$this->parent = $parent;
$this->child = $child;
}
/**
* Execute the job.
*/
public function handle(): void
{
$this->cloneCompany();
$this->cloneImages();
sleep(10);
var_dump($this->parent->alias . ' - ' . $this->child->alias);
}
private function cloneCompany()
{
}
private function cloneImages()
{
}
}
php artisan queue:listen
CompanyCloneJob::dispatch($parentCompany, $childCompany);