71 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App;
 | 
						|
 | 
						|
use Illuminate\Contracts\Auth\MustVerifyEmail;
 | 
						|
use Illuminate\Foundation\Auth\User as Authenticatable;
 | 
						|
use Illuminate\Notifications\Notifiable;
 | 
						|
use Laravel\Passport\HasApiTokens;
 | 
						|
 | 
						|
class User extends Authenticatable
 | 
						|
{
 | 
						|
    use Notifiable, HasApiTokens;
 | 
						|
    
 | 
						|
    const TABLE_NAME = 'users';
 | 
						|
    const DATABASE_SCHEME = 'e_traffic';
 | 
						|
    
 | 
						|
    protected $connection = self::DATABASE_SCHEME;
 | 
						|
    
 | 
						|
    /**
 | 
						|
     * The field contains the name of the tables with users
 | 
						|
     *
 | 
						|
     * @var string
 | 
						|
     */
 | 
						|
    protected $table = self::TABLE_NAME;
 | 
						|
 | 
						|
    /**
 | 
						|
     * The attributes that are mass assignable.
 | 
						|
     *
 | 
						|
     * @var array
 | 
						|
     */
 | 
						|
    protected $fillable = [
 | 
						|
        'name', 'email', 'password',
 | 
						|
    ];
 | 
						|
 | 
						|
    /**
 | 
						|
     * The attributes that should be hidden for arrays.
 | 
						|
     *
 | 
						|
     * @var array
 | 
						|
     */
 | 
						|
    protected $hidden = [
 | 
						|
        'password', 'remember_token',
 | 
						|
    ];
 | 
						|
 | 
						|
    /**
 | 
						|
     * The attributes that should be cast to native types.
 | 
						|
     *
 | 
						|
     * @var array
 | 
						|
     */
 | 
						|
    protected $casts = [
 | 
						|
        'email_verified_at' => 'datetime',
 | 
						|
    ];
 | 
						|
    
 | 
						|
    /**
 | 
						|
     * @param int $id
 | 
						|
     * @return User or NULL
 | 
						|
     */
 | 
						|
    public static function getById($id)
 | 
						|
    {
 | 
						|
        return self::query()->where('id', '=', intval($id))->first();
 | 
						|
    }
 | 
						|
    
 | 
						|
    /**
 | 
						|
     * @param string $username
 | 
						|
     * @return User or NULL
 | 
						|
     */
 | 
						|
    public static function getByUsername($username)
 | 
						|
    {
 | 
						|
        return self::query()->where('name', '=', trim($username))->first();
 | 
						|
    }
 | 
						|
}
 |