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();
|
return $this->adminUser->isAdministrator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认当前员工是否是店长
|
||||||
|
*/
|
||||||
|
public function isStoreMaster(): bool
|
||||||
|
{
|
||||||
|
return $this->store_id && $this->store?->master_id == $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户身份
|
* 用户身份
|
||||||
* user: 普通员工, store: 店长, admin: 管理员
|
* user: 普通员工, store: 店长, admin: 管理员
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function userRole()
|
public function userRole(): array
|
||||||
{
|
{
|
||||||
$role = [
|
return collect()
|
||||||
$this->store_id && $this->store->master_id == $this->id ? UserRole::Store : UserRole::User
|
->when($this->isAdministrator(), fn ($collection) => $collection->push(UserRole::Admin))
|
||||||
];
|
->when($this->isStoreMaster(), fn ($collection) => $collection->push(UserRole::Store))
|
||||||
if ($this->isAdministrator()) {
|
->whenEmpty(fn ($collection) => $collection->push(UserRole::User))
|
||||||
array_push($role, UserRole::Admin);
|
->all();
|
||||||
}
|
|
||||||
return $role;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function employeeStatusText(): Attribute
|
protected function employeeStatusText(): Attribute
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue