You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
2.2 KiB
PHP
106 lines
2.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
* To change this license header, choose License Headers in Project Properties.
|
|
* To change this template file, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Contracts\Auth\Access\Authorizable;
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
|
use Illuminate\Contracts\Auth\CanResetPassword;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Description of OAuth2User
|
|
*
|
|
* @author Andrey Pokidov <pokidov@e-traffic.ru>
|
|
*/
|
|
class OAuth2User extends Model implements Authenticatable, Authorizable
|
|
{
|
|
const TABLE_NAME = 'oauth2_users';
|
|
|
|
protected $table = self::TABLE_NAME;
|
|
|
|
public static function getById($id)
|
|
{
|
|
return self::query()->where('id', '=', intval($id))->first();
|
|
}
|
|
|
|
/**
|
|
* Determine if the entity has a given ability.
|
|
*
|
|
* @param string $ability
|
|
* @param array|mixed $arguments
|
|
* @return bool
|
|
*/
|
|
public function can($ability, $arguments = [])
|
|
{
|
|
return app(Gate::class)->forUser($this)->check($ability, $arguments);
|
|
}
|
|
|
|
/**
|
|
* Get the name of the unique identifier for the user.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getAuthIdentifierName()
|
|
{
|
|
return 'id';
|
|
}
|
|
|
|
/**
|
|
* Get the unique identifier for the user.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function getAuthIdentifier()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* Get the password for the user.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getAuthPassword()
|
|
{
|
|
return '';
|
|
}
|
|
|
|
/**
|
|
* Get the token value for the "remember me" session.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getRememberToken()
|
|
{
|
|
return $this->rememberToken;
|
|
}
|
|
|
|
/**
|
|
* Set the token value for the "remember me" session.
|
|
*
|
|
* @param string $value
|
|
* @return void
|
|
*/
|
|
public function setRememberToken($value)
|
|
{
|
|
$this->remember_token = trim(strval($value));
|
|
}
|
|
|
|
/**
|
|
* Get the column name for the "remember me" token.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getRememberTokenName()
|
|
{
|
|
return 'remember_token';
|
|
}
|
|
}
|