generated from liutk/owl-admin-base
api sign_repair delete
parent
d9b3488359
commit
ee7c6dce22
|
|
@ -9,6 +9,7 @@ use Illuminate\Validation\Rule;
|
|||
use Slowlyo\OwlAdmin\Admin;
|
||||
use App\Enums\CheckStatus;
|
||||
use Slowlyo\OwlAdmin\Models\AdminUser;
|
||||
use App\Exceptions\RuntimeException;
|
||||
|
||||
class EmployeeSignRepairService extends BaseService
|
||||
{
|
||||
|
|
@ -74,7 +75,7 @@ class EmployeeSignRepairService extends BaseService
|
|||
$createRules = [
|
||||
'employee_id' => ['required'],
|
||||
'sign_time' => ['required'],
|
||||
'date' => ['required'],
|
||||
'date' => ['required', 'date'],
|
||||
'store_id' => ['required'],
|
||||
'reason' => ['required'],
|
||||
];
|
||||
|
|
@ -103,4 +104,22 @@ class EmployeeSignRepairService extends BaseService
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delete(string $ids): mixed
|
||||
{
|
||||
$list = $this->query()->with(['workflow'])->whereIn('id', explode(',', $ids))->get();
|
||||
foreach ($list as $item) {
|
||||
$workflow = $item->workflow;
|
||||
if ($workflow) {
|
||||
if ($workflow->check_status == CheckStatus::Processing) {
|
||||
throw new RuntimeException(CheckStatus::Processing->text() . ', 无法删除');
|
||||
}
|
||||
if ($workflow->check_status == CheckStatus::Success) {
|
||||
throw new RuntimeException(CheckStatus::Success->text() . ', 无法删除');
|
||||
}
|
||||
}
|
||||
$item->delete();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,9 +89,6 @@ class SignRepairController extends Controller
|
|||
{
|
||||
$user = $this->guard()->user();
|
||||
$model = EmployeeSignRepair::with(['workflow'])->where('employee_id', $user->id)->findOrFail($id);
|
||||
if (!$model->canUpdate()) {
|
||||
throw new RuntimeException('审核中, 无法删除');
|
||||
}
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
|
|
|||
Loading…
Reference in New Issue