mirror of
https://github.com/koel/koel
synced 2024-12-21 18:13:13 +00:00
27 lines
720 B
PHP
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.'
|
|
);
|
|
}
|
|
}
|
|
}
|