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

51 lines
917 B
PHP
Raw Permalink Normal View History

2020-02-26 13:59:58 +00:00
<?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;
2021-06-27 19:01:43 +00:00
if($uuid === $value)
return false;
2020-02-26 13:59:58 +00:00
$user = User::where('uuid', '=', $uuid)->first();
return empty($user);
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
2021-06-27 19:01:43 +00:00
return 'Username: :value is incorrect or already in use';
2020-02-26 13:59:58 +00:00
}
}