2
0
Fork 0
mirror of https://github.com/koel/koel synced 2024-12-24 19:43:06 +00:00
koel/app/Services/SongStorages/SongStorage.php
2024-07-06 17:45:02 +02:00

26 lines
705 B
PHP

<?php
namespace App\Services\SongStorages;
use App\Enums\SongStorageType;
use App\Exceptions\KoelPlusRequiredException;
use App\Models\Song;
use App\Models\User;
use Illuminate\Http\UploadedFile;
abstract class SongStorage
{
abstract protected function getStorageType(): SongStorageType;
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(
$this->getStorageType()->supported(),
new KoelPlusRequiredException('The storage driver is only supported in Koel Plus.')
);
}
}