2024-02-04 20:31:01 +00:00
|
|
|
<?php
|
|
|
|
|
2024-02-23 18:36:02 +00:00
|
|
|
namespace App\Services\SongStorages;
|
2024-02-04 20:31:01 +00:00
|
|
|
|
2024-04-26 13:35:26 +00:00
|
|
|
use App\Enums\SongStorageType;
|
2024-02-05 13:27:17 +00:00
|
|
|
use App\Exceptions\KoelPlusRequiredException;
|
2024-02-04 20:31:01 +00:00
|
|
|
use App\Models\Song;
|
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Http\UploadedFile;
|
|
|
|
|
2024-02-05 13:27:17 +00:00
|
|
|
abstract class SongStorage
|
2024-02-04 20:31:01 +00:00
|
|
|
{
|
2024-09-08 11:21:06 +00:00
|
|
|
abstract public function getStorageType(): SongStorageType;
|
2024-04-26 13:35:26 +00:00
|
|
|
|
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;
|
|
|
|
|
2024-09-08 11:21:06 +00:00
|
|
|
abstract public function testSetup(): void;
|
|
|
|
|
2024-04-04 22:20:42 +00:00
|
|
|
protected function assertSupported(): void
|
2024-02-05 13:27:17 +00:00
|
|
|
{
|
|
|
|
throw_unless(
|
2024-04-26 13:35:26 +00:00
|
|
|
$this->getStorageType()->supported(),
|
2024-02-05 13:27:17 +00:00
|
|
|
new KoelPlusRequiredException('The storage driver is only supported in Koel Plus.')
|
|
|
|
);
|
|
|
|
}
|
2024-02-04 20:31:01 +00:00
|
|
|
}
|