generated from liutk/owl-admin-base
Update
parent
cce8b118c1
commit
498a2df89d
|
|
@ -27,7 +27,7 @@ class EmployeeService extends BaseService
|
|||
$validate = $this->validate($data);
|
||||
if ($validate !== true) {
|
||||
$this->setError($validate);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
// 添加管理员信息
|
||||
|
|
@ -87,13 +87,8 @@ class EmployeeService extends BaseService
|
|||
|
||||
/**
|
||||
* 员工离职/还原
|
||||
*
|
||||
* @param Employee $user
|
||||
* @param array $options {leave_at: 离职时间}
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function leave(Employee $user, $options = [])
|
||||
public function leave(Employee $user, $options = []): bool
|
||||
{
|
||||
if ($user->employee_status == EmployeeStatus::Online) {
|
||||
// 店长不能离职
|
||||
|
|
@ -101,11 +96,12 @@ class EmployeeService extends BaseService
|
|||
return $this->setError('请先设置新店长');
|
||||
}
|
||||
$user->update([
|
||||
'leave_at' => data_get($options, 'leave_at', now()),
|
||||
'leave_at' => $options['leave_at'] ?? now(),
|
||||
'employee_status' => EmployeeStatus::Offline,
|
||||
]);
|
||||
} else {
|
||||
$user->update([
|
||||
'join_at' => now(),
|
||||
'leave_at' => null,
|
||||
'employee_status' => EmployeeStatus::Online,
|
||||
]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue