Return newly added customer note as array in API response
- Updated `addNote` in `users_o` to return the `customer_notes_o` object. - Modified `customerNotes` endpoint to include note details in the success response. - Introduced `asArray` method in `customer_notes_o` for structured API responses.
This commit is contained in:
@@ -74,11 +74,11 @@ class customerNotes
|
||||
if (!$customer->exists()) {
|
||||
$response->error('Customer not found', 400);
|
||||
}
|
||||
$customer->addNote((int)$customer->id, (string)$data['note'], (int)$user->id);
|
||||
$note = $customer->addNote((int)$customer->id, (string)$data['note'], (int)$user->id);
|
||||
// Log the incident
|
||||
(new logs_o())->add('customer_notes', 'global', 1, $user->id, 'ADD_CUSTOMER_NOTE', 'Successfully added a customer note');
|
||||
// Return a success message
|
||||
$response->success(['message' => 'Customer note added']);
|
||||
$response->success($note->asArray());
|
||||
} else {
|
||||
// Log the incident
|
||||
(new logs_o())->add('customer_notes', 'global', 1, 0, 'ADD_CUSTOMER_NOTE', 'No user found, or invalid session');
|
||||
|
||||
Reference in New Issue
Block a user