build: initialize RetroHub with Laravel, Inertia, Vue, and Horizon
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Features\Games\Models\Game;
|
||||
use App\Features\Scraper\Services\ScraperService;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ScrapeCoverJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
public Game $game,
|
||||
) {}
|
||||
|
||||
public function handle(ScraperService $scraper): void
|
||||
{
|
||||
$result = $scraper->search($this->game->title, $this->game->console?->slug);
|
||||
|
||||
if ($result->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$bestMatch = $result->first();
|
||||
|
||||
if ($bestMatch->coverUrl) {
|
||||
$path = $scraper->downloadCover($bestMatch->coverUrl, $this->game);
|
||||
$this->game->update(['cover_path' => $path]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user