26 lines
686 B
PHP
26 lines
686 B
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Illuminate\Translation\PotentiallyTranslatedString;
|
|
|
|
class XfUserExists implements ValidationRule
|
|
{
|
|
/**
|
|
* Run the validation rule.
|
|
*
|
|
* @param Closure(string, ?string=): PotentiallyTranslatedString $fail
|
|
*/
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
$user = DB::connection('xenforo')->table('user')->where('user_id', $value)->first();
|
|
if( !$user ){
|
|
$fail("The user ID {$value} does not exist.");
|
|
}
|
|
}
|
|
}
|