mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-09-06 20:55:04 +02:00
47 lines
910 B
PHP
47 lines
910 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Rules\Storage;
|
|
|
|
use Illuminate\Contracts\Filesystem\Filesystem;
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
/**
|
|
* Class StorageDirectoryExistsRule.
|
|
*/
|
|
class StorageDirectoryExistsRule implements Rule
|
|
{
|
|
/**
|
|
* Create a new rule instance.
|
|
*
|
|
* @param Filesystem $fs
|
|
* @return void
|
|
*/
|
|
public function __construct(protected readonly Filesystem $fs)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Determine if the validation rule passes.
|
|
*
|
|
* @param string $attribute
|
|
* @param mixed $value
|
|
* @return bool
|
|
*/
|
|
public function passes($attribute, $value): bool
|
|
{
|
|
return $this->fs->directoryExists($value);
|
|
}
|
|
|
|
/**
|
|
* Get the validation error message.
|
|
*
|
|
* @return string|array
|
|
*/
|
|
public function message(): string|array
|
|
{
|
|
return __('validation.directory_exists');
|
|
}
|
|
}
|