mirror of
https://github.com/koel/koel
synced 2024-11-12 23:47:09 +00:00
28 lines
714 B
PHP
28 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.';
|
|
}
|
|
}
|