2020-04-27 18:55:12 +00:00
|
|
|
<?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;
|
2020-04-27 18:55:12 +00:00
|
|
|
|
|
|
|
class ScrobbleJob implements ShouldQueue
|
|
|
|
{
|
2020-09-06 21:20:42 +00:00
|
|
|
use Dispatchable;
|
|
|
|
use InteractsWithQueue;
|
|
|
|
use Queueable;
|
|
|
|
use SerializesModels;
|
2020-04-27 18:55:12 +00:00
|
|
|
|
2022-08-08 16:00:59 +00:00
|
|
|
public function __construct(public User $user, public Song $song, public int $timestamp)
|
2020-04-27 18:55:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handle(LastfmService $lastfmService): void
|
|
|
|
{
|
2022-08-08 16:00:59 +00:00
|
|
|
$lastfmService->scrobble($this->song, $this->user, $this->timestamp);
|
2020-04-27 18:55:12 +00:00
|
|
|
}
|
|
|
|
}
|