koel/app/Jobs/ScrobbleJob.php

30 lines
701 B
PHP
Raw Normal View History

<?php
namespace App\Jobs;
use App\Models\Song;
use App\Models\User;
use App\Services\LastfmService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
2020-09-06 21:20:42 +00:00
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class ScrobbleJob implements ShouldQueue
{
2020-09-06 21:20:42 +00:00
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
2022-08-08 16:00:59 +00:00
public function __construct(public User $user, public Song $song, public int $timestamp)
{
}
public function handle(LastfmService $lastfmService): void
{
2022-08-08 16:00:59 +00:00
$lastfmService->scrobble($this->song, $this->user, $this->timestamp);
}
}