batch()?->cancelled()) { return; } $this->image->fill([ 'isCover' => $this->getCoverFlag(), 'isProcessing' => false, ]); $this->image->save(); // TODO: Dispatch image cleaned event } private function getCoverFlag() : bool { if(!$this->image->album->hasCover && $this->image->album->images->sortBy('id')->first()->id == $this->image->id) { return true; } return false; } public function failed(?Throwable $exception): void { Log::error($exception, [ 'image' => $this->image, ]); } }