Files
RomhackPlaza/app/Rules/XfUserExists.php

26 lines
686 B
PHP
Raw Permalink Normal View History

2026-06-02 20:54:10 +02:00
<?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.");
}
}
}