add policies

This commit is contained in:
2023-11-28 23:48:21 +05:00
parent 56a7255e4a
commit ede8513ebf
8 changed files with 521 additions and 0 deletions

View File

@@ -45,4 +45,24 @@ class User extends Authenticatable
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
/**
* User is me?
*/
public function isMe(): bool
{
return $this->email === 'nurmuhammet@mail.com';
}
/**
* Is user admin?
*/
public function isAdmin(): bool
{
if ($this->isMe()) {
return true;
}
return $this->hasRole(['king', 'superadmin', 'admin']);
}
}