63 lines
1.1 KiB
PHP
63 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\UserAdjustments\Traits;
|
|
|
|
trait RoleCheckers
|
|
{
|
|
/**
|
|
* Check if user is me.
|
|
*/
|
|
public function isMe(): bool
|
|
{
|
|
return $this->email === 'nurmuhammet@mail.com';
|
|
}
|
|
|
|
/**
|
|
* Check if user is super admin.
|
|
*/
|
|
public function isSuperAdmin(): bool
|
|
{
|
|
if ($this->isMe()) {
|
|
return true;
|
|
}
|
|
|
|
return $this->hasRole('superadmin');
|
|
}
|
|
|
|
/**
|
|
* Check if user is admin.
|
|
*/
|
|
public function isAdmin(): bool
|
|
{
|
|
if ($this->isMe()) {
|
|
return true;
|
|
}
|
|
|
|
return $this->hasRole(['king', 'superadmin', 'admin']);
|
|
}
|
|
|
|
/**
|
|
* Check if user is operator.
|
|
*/
|
|
public function isOperator(): bool
|
|
{
|
|
return $this->hasRole('operator');
|
|
}
|
|
|
|
/**
|
|
* Check if user is a currency maintainer.
|
|
*/
|
|
public function isCurrencyMaintainer(): bool
|
|
{
|
|
return $this->hasRole('currency_maintainer');
|
|
}
|
|
|
|
/**
|
|
* Is System User
|
|
*/
|
|
public function isSystemUser(): bool
|
|
{
|
|
return $this->roles->count > 0;
|
|
}
|
|
}
|