mirror of
https://github.com/brian8544/turtle-wow.git
synced 2024-12-31 20:04:35 +00:00
29 lines
798 B
PHP
29 lines
798 B
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use App\Models\forum\PhpBBUser;
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
|
|
class CheckForumUsername implements ValidationRule
|
|
{
|
|
/**
|
|
* Run the validation rule.
|
|
*
|
|
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
|
|
*/
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
$account_forum_clean = strtolower($value);
|
|
$account_forum = ucfirst($account_forum_clean);
|
|
|
|
$phpBBUserGroup = PhpBBUser::where('username_clean', $account_forum_clean)
|
|
->orWhere('username', $account_forum)->first();
|
|
|
|
if ($phpBBUserGroup) {
|
|
$fail(__('register_modal')['exception']['existing_forum_username']);
|
|
}
|
|
}
|
|
}
|