Initial commit
This commit is contained in:
23
app/Rules/PublicFileExists.php
Normal file
23
app/Rules/PublicFileExists.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Translation\PotentiallyTranslatedString;
|
||||
|
||||
class PublicFileExists implements ValidationRule
|
||||
{
|
||||
/**
|
||||
* Run the validation rule.
|
||||
*
|
||||
* @param Closure(string, ?string=): PotentiallyTranslatedString $fail
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if(!Storage::disk('public')->exists($value) ) {
|
||||
$fail("The file {$value} does not exist.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user