profile->id; } /** * Get the middleware the job should pass through. * * @return array */ public function middleware(): array { return [(new WithoutOverlapping("avatar-create:{$this->profile->id}"))->shared()->dontRelease()]; } /** * Create a new job instance. * * @return void */ public function __construct(Profile $profile) { $this->profile = $profile->withoutRelations(); } /** * Execute the job. * * @return void */ public function handle() { $profile = $this->profile; $isRemote = (bool) $profile->private_key == null; $path = 'public/avatars/default.jpg'; Avatar::updateOrCreate( [ 'profile_id' => $profile->id, ], [ 'media_path' => $path, 'change_count' => 0, 'is_remote' => $isRemote, 'last_processed_at' => now() ] ); } }