koel/app/Services/SongStorages/Concerns/DeletesUsingFilesystem.php

22 lines
507 B
PHP
Raw Normal View History

2024-04-26 13:35:26 +00:00
<?php
namespace App\Services\SongStorages\Concerns;
use App\Models\Song;
use Illuminate\Contracts\Filesystem\Filesystem as IlluminateFilesystem;
use League\Flysystem\Filesystem;
trait DeletesUsingFilesystem
{
private function deleteUsingFileSystem(Filesystem | IlluminateFilesystem $disk, Song $song, bool $backup): void
{
$path = $song->storage_metadata->getPath();
if ($backup) {
$disk->move($path, "backup/$path");
}
$disk->delete($path);
}
}