mirror of
https://github.com/koel/koel
synced 2024-11-24 13:13:05 +00:00
29 lines
714 B
PHP
29 lines
714 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Rules;
|
||
|
|
||
|
use Illuminate\Contracts\Validation\Rule;
|
||
|
use Illuminate\Support\Facades\File;
|
||
|
|
||
|
class MediaPath implements Rule
|
||
|
{
|
||
|
public function passes($attribute, $value): bool
|
||
|
{
|
||
|
if (config('koel.storage_driver') === 'local') {
|
||
|
return $value && File::isDirectory($value) && File::isReadable($value);
|
||
|
}
|
||
|
|
||
|
// Setting a media path is not required for non-local storage drivers.
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public function message(): string
|
||
|
{
|
||
|
if (config('koel.storage_driver') === 'local') {
|
||
|
return 'Media path is required for local storage.';
|
||
|
}
|
||
|
|
||
|
return 'Media path is not required for non-local storage.';
|
||
|
}
|
||
|
}
|