koel/app/Services/SongStorages/SongStorage.php

27 lines
705 B
PHP
Raw Normal View History

<?php
namespace App\Services\SongStorages;
2024-04-26 13:35:26 +00:00
use App\Enums\SongStorageType;
use App\Exceptions\KoelPlusRequiredException;
use App\Models\Song;
use App\Models\User;
use Illuminate\Http\UploadedFile;
abstract class SongStorage
{
2024-04-26 13:35:26 +00:00
abstract protected function getStorageType(): SongStorageType;
2024-04-04 22:20:42 +00:00
abstract public function storeUploadedFile(UploadedFile $file, User $uploader): Song;
abstract public function delete(Song $song, bool $backup = false): void;
protected function assertSupported(): void
{
throw_unless(
2024-04-26 13:35:26 +00:00
$this->getStorageType()->supported(),
new KoelPlusRequiredException('The storage driver is only supported in Koel Plus.')
);
}
}