You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
976 B

<?php
/**
* 更新公司信息
*/
namespace App\Jobs;
use App\Models\Company;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class UpdateCompanyJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 3;
public $timeout = 300;
public $userId;
/**
* Create a new job instance.
*
* @param int $userId 用户ID
*/
public function __construct($userId)
{
$this->userId = $userId;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$user = User::find($this->userId);
if (!$user) {
return;
}
// 调用模型方法更新公司信息
Company::updateCompanyFromUser($user);
}
}