This commit is contained in:
baodev0
2026-10-08 11:25:28 +07:00
parent 1544629a1f
commit 8651dde6b1
45 changed files with 1543 additions and 357 deletions
@@ -44,6 +44,30 @@ class ServiceController extends Controller
return response()->json(['error' => false, 'data' => $service]);
}
public function bulkAction(Request $request): JsonResponse
{
$data = $request->validate([
'ids' => 'required|array|min:1',
'ids.*' => 'integer|distinct|exists:services,id',
'action' => 'required|in:activate,suspend,cancel,detach-customer',
]);
$updates = match ($data['action']) {
'activate' => ['status' => 'active', 'suspended_at' => null, 'cancelled_at' => null],
'suspend' => ['status' => 'suspended', 'suspended_at' => now()],
'cancel' => ['status' => 'cancelled', 'cancelled_at' => now()],
'detach-customer' => ['customer_id' => null],
};
$updated = Service::whereIn('id', $data['ids'])->update($updates);
return response()->json([
'error' => false,
'message' => "Đã cập nhật {$updated} dịch vụ.",
'data' => ['updated' => $updated],
]);
}
public function detachCustomer(int $id): JsonResponse
{
$service = Service::findOrFail($id);