2
0
Fork 0
mirror of https://github.com/koel/koel synced 2024-12-20 01:23:16 +00:00
koel/app/Rules/MediaPath.php
2024-07-06 17:45:04 +02:00

27 lines
720 B
PHP

<?php
namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Support\Facades\File;
class MediaPath implements ValidationRule
{
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$passes = false;
if (config('koel.storage_driver') === 'local') {
$passes = $value && File::isDirectory($value) && File::isReadable($value);
}
if (!$passes) {
$fail(
config('koel.storage_driver') === 'local'
? 'Media path is required for local storage.'
: 'Media path is not required for non-local storage.'
);
}
}
}