3
0
Fork 0
This repository has been archived on 2024-11-14. You can view files and clone it, but cannot push or open issues or pull requests.
ThemeParkPlus-Panel/app/Rules/UUID.php
2020-02-26 14:59:58 +01:00

47 lines
852 B
PHP

<?php
namespace App\Rules;
use App\Cache\Cache;
use App\User;
use Illuminate\Contracts\Validation\Rule;
class UUID implements Rule
{
/**
* Create a new rule instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
$uuid = Cache::getUUID($value);
if(empty($uuid))
return false;
$user = User::where('uuid', '=', $uuid)->first();
return empty($user);
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return 'Username: :attribute is already in use';
}
}