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,6 +97,7 @@ class ServiceDeskController extends Controller
}
}
try {
$entry = GuestEntryService::recordEntry([
'carnet_id' => $carnetId,
'member_id' => $memberId,
......@@ -113,10 +114,13 @@ class ServiceDeskController extends Controller
'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