Files
E-Vote/app/User.php
T

54 lines
1.1 KiB
PHP

<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
use Lab404\Impersonate\Models\Impersonate;
class User extends Authenticatable
{
use HasApiTokens, Notifiable, Impersonate;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'role'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function canImpersonate()
{
// Limit to main admin to avoid privilege escalation.
return (int) $this->id === 1;
}
public function canBeImpersonated()
{
// Do not allow impersonating main admin.
return (int) $this->id !== 1;
}
public function allowanceClaimCodes()
{
return $this->hasMany(AllowanceClaimCode::class, 'used_by_admin_id');
}
public function allowancePayouts()
{
return $this->hasMany(AllowancePayout::class, 'paid_by_admin_id');
}
}