generated from liutk/owl-admin-base
Update
parent
cce8b118c1
commit
498a2df89d
|
|
@ -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) {
|
if ($user->employee_status == EmployeeStatus::Online) {
|
||||||
// 店长不能离职
|
// 店长不能离职
|
||||||
|
|
@ -101,11 +96,12 @@ class EmployeeService extends BaseService
|
||||||
return $this->setError('请先设置新店长');
|
return $this->setError('请先设置新店长');
|
||||||
}
|
}
|
||||||
$user->update([
|
$user->update([
|
||||||
'leave_at' => data_get($options, 'leave_at', now()),
|
'leave_at' => $options['leave_at'] ?? now(),
|
||||||
'employee_status' => EmployeeStatus::Offline,
|
'employee_status' => EmployeeStatus::Offline,
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$user->update([
|
$user->update([
|
||||||
|
'join_at' => now(),
|
||||||
'leave_at' => null,
|
'leave_at' => null,
|
||||||
'employee_status' => EmployeeStatus::Online,
|
'employee_status' => EmployeeStatus::Online,
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue