20 lines
501 B
PHP
20 lines
501 B
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class ValidateAuditionKey implements ValidationRule
|
|
{
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
// Extract the key from the attribute
|
|
$key = explode('.', $attribute)[1];
|
|
if (! DB::table('auditions')->where('id', $key)->exists()) {
|
|
$fail('Invalid audition id provided');
|
|
}
|
|
}
|
|
}
|