65 lines
1.6 KiB
PHP
65 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Core\Auth;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Yadahan\AuthenticationLog\AuthenticationLogable;
|
|
use HighIdeas\UsersOnline\Traits\UsersOnlineTrait;
|
|
use Sebastienheyd\Boilerplate\Models\User as parentUser;
|
|
|
|
class User extends parentUser
|
|
{
|
|
// use UserHasTeams;
|
|
use AuthenticationLogable, SoftDeletes, UsersOnlineTrait;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = ['active', 'last_name', 'first_name', 'username', 'email', 'password', 'remember_token', 'last_login'];
|
|
|
|
protected $hidden = ['password', 'remember_token'];
|
|
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'email_verified_at' => 'datetime',
|
|
];
|
|
|
|
public function passwordSecurity()
|
|
{
|
|
return $this->hasOne('App\Models\Core\Auth\PasswordSecurity');
|
|
}
|
|
|
|
public function teams()
|
|
{
|
|
return $this->hasManyThrough(\App\Models\Core\Auth\Team::class, \App\Models\Core\Auth\TeamUser::class, 'user_id', 'id', 'id', 'team_id');
|
|
}
|
|
|
|
public function scopeByTeam($query, $id)
|
|
{
|
|
return $query->whereHas(
|
|
'teams', function ($query) use ($id) {
|
|
$query->where('id', $id);
|
|
}
|
|
);
|
|
}
|
|
|
|
public function scopeByUniqueTeam($query)
|
|
{
|
|
return $query->has('teams', '=', 1);
|
|
}
|
|
|
|
public function scopeActive($query)
|
|
{
|
|
return $query->where('active', 1);
|
|
}
|
|
}
|