generated from liutk/owl-admin-base
Update
parent
e6058fbdc7
commit
74ff9a1c41
|
|
@ -96,20 +96,26 @@ class Employee extends Model implements AuthenticatableContract
|
|||
return $this->adminUser->isAdministrator();
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认当前员工是否是店长
|
||||
*/
|
||||
public function isStoreMaster(): bool
|
||||
{
|
||||
return $this->store_id && $this->store?->master_id == $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户身份
|
||||
* user: 普通员工, store: 店长, admin: 管理员
|
||||
* @return array
|
||||
*/
|
||||
public function userRole()
|
||||
public function userRole(): array
|
||||
{
|
||||
$role = [
|
||||
$this->store_id && $this->store->master_id == $this->id ? UserRole::Store : UserRole::User
|
||||
];
|
||||
if ($this->isAdministrator()) {
|
||||
array_push($role, UserRole::Admin);
|
||||
}
|
||||
return $role;
|
||||
return collect()
|
||||
->when($this->isAdministrator(), fn ($collection) => $collection->push(UserRole::Admin))
|
||||
->when($this->isStoreMaster(), fn ($collection) => $collection->push(UserRole::Store))
|
||||
->whenEmpty(fn ($collection) => $collection->push(UserRole::User))
|
||||
->all();
|
||||
}
|
||||
|
||||
protected function employeeStatusText(): Attribute
|
||||
|
|
|
|||
Loading…
Reference in New Issue