Initial commit
This commit is contained in:
commit
b105bd7db7
171 changed files with 28322 additions and 0 deletions
47
app/Rules/UUID.php
Normal file
47
app/Rules/UUID.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?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';
|
||||
}
|
||||
}
|
Reference in a new issue