Commit be157e40 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(service-desk): add try-catch + fix JSON serialization of entry object

The issueTicket response was passing the raw Model object to json(),
which could fail serialization. Now returns entry_id instead, and
wraps recordEntry in try-catch for proper error reporting.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent ec725ab5
......@@ -97,26 +97,30 @@ class ServiceDeskController extends Controller
}
}
$entry = GuestEntryService::recordEntry([
'carnet_id' => $carnetId,
'member_id' => $memberId,
'guest_name' => $guestName,
'guest_phone' => trim((string) $request->post('guest_phone', '')),
'guest_national_id' => '',
'guest_count' => $guestCount,
'entry_date' => date('Y-m-d'),
'entry_time' => date('H:i:s'),
'facility_id' => $facilityId,
'activity_type' => $activityType,
'amount_paid' => $amountPaid,
'notes' => $notes,
'recorded_by' => $employee ? (int) $employee->id : null,
'status' => 'active',
]);
try {
$entry = GuestEntryService::recordEntry([
'carnet_id' => $carnetId,
'member_id' => $memberId,
'guest_name' => $guestName,
'guest_phone' => trim((string) $request->post('guest_phone', '')),
'guest_national_id' => '',
'guest_count' => $guestCount,
'entry_date' => date('Y-m-d'),
'entry_time' => date('H:i:s'),
'facility_id' => $facilityId,
'activity_type' => $activityType,
'amount_paid' => $amountPaid,
'notes' => $notes,
'recorded_by' => $employee ? (int) $employee->id : null,
'status' => 'active',
]);
} catch (\Throwable $e) {
return $this->json(['success' => false, 'error' => 'فشل الإصدار: ' . $e->getMessage()]);
}
return $this->json([
'success' => true,
'entry' => $entry,
'entry_id' => (int) $entry->id,
'message' => 'تم إصدار التذكرة بنجاح',
]);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment