fixed the repeated notes on edit

This commit is contained in:
Kwesi Banson
2024-03-13 16:21:55 +00:00
parent acda110be1
commit 1a4a3acfda
2 changed files with 18 additions and 16 deletions

View File

@@ -15,7 +15,7 @@ use Carbon\Carbon;
class ClientsController extends Controller class ClientsController extends Controller
{ {
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* *
@@ -313,27 +313,21 @@ class ClientsController extends Controller
'notes_body' => 'required' 'notes_body' => 'required'
]); ]);
$auth_user = session('current_user'); $auth_user = session('current_user');
$notes_arr = [ $note = Models\ClientNote::find($request->note_id);
'notes_body' => $request->notes_body, $note->notes_body = $request->notes_body;
'services' => implode(',', $request->services), $note->services = implode(',', $request->services);
'auth_user_id' => $auth_user['id'],
'client_id' => $request->client_id
];
if ($request->has('highlight')) { if ($request->has('highlight')) {
$notes_arr['highlight'] = 'YES'; $note->highlight = 'YES';
} }
$result = $note->save();
$notes = Models\ClientNote::with('client_info', 'created_by_info')->find($request->note_id);
//dd($notes_arr);
// change this to update
$result = Models\ClientNote::create($notes_arr);
$notes = Models\ClientNote::with('client_info', 'created_by_info')->find($result->id);
//todo : send emails
//dispatch(new SendNewNotesEmailAlert($notes)); //dispatch(new SendNewNotesEmailAlert($notes));
if ($result) { if ($result) {
$data = ['code' => 1, 'msg' => 'Notes successfully added']; $data = ['code' => 1, 'msg' => 'Notes successfully updated'];
} }
else{ else{
$data = ['code' => 3, 'msg' => 'Your request could not be handled at this time']; $data = ['code' => 3, 'msg' => 'Your request could not be handled at this time'];

8
mphatso-notes.md Normal file
View File

@@ -0,0 +1,8 @@
INSERT INTO `client_notes` (`id`, `client_id`, `services`, `auth_user_id`, `notes_body`, `highlight`, `created_at`, `updated_at`)
VALUES
(955, '229', 'A2P', 15, 'A bilateral prepaid agreement has been signed by both Click Mobile and Telxio Networks.\r\nThe next step is to exchange tech forms for the interconnection.', 'NO', '2024-03-11 11:34:14', '2024-03-11 11:34:14');
INSERT INTO `client_notes` (`id`, `client_id`, `services`, `auth_user_id`, `notes_body`, `highlight`, `created_at`, `updated_at`)
VALUES
(954, '229', 'A2P', 15, 'A bilateral prepaid agreement has been signed by both Click Mobile and Telxio.\r\nThe next stepp is to excahnge tech forms for the interconnection.', 'NO', '2024-03-11 08:00:02', '2024-03-11 08:00:02');