fixed the repeated notes on edit
This commit is contained in:
@@ -15,7 +15,7 @@ use Carbon\Carbon;
|
||||
|
||||
|
||||
class ClientsController extends Controller
|
||||
{
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
@@ -313,27 +313,21 @@ class ClientsController extends Controller
|
||||
'notes_body' => 'required'
|
||||
]);
|
||||
$auth_user = session('current_user');
|
||||
$notes_arr = [
|
||||
'notes_body' => $request->notes_body,
|
||||
'services' => implode(',', $request->services),
|
||||
'auth_user_id' => $auth_user['id'],
|
||||
'client_id' => $request->client_id
|
||||
];
|
||||
$note = Models\ClientNote::find($request->note_id);
|
||||
$note->notes_body = $request->notes_body;
|
||||
$note->services = implode(',', $request->services);
|
||||
|
||||
if ($request->has('highlight')) {
|
||||
$notes_arr['highlight'] = 'YES';
|
||||
$note->highlight = 'YES';
|
||||
}
|
||||
$result = $note->save();
|
||||
|
||||
|
||||
//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
|
||||
$notes = Models\ClientNote::with('client_info', 'created_by_info')->find($request->note_id);
|
||||
|
||||
//dispatch(new SendNewNotesEmailAlert($notes));
|
||||
|
||||
if ($result) {
|
||||
$data = ['code' => 1, 'msg' => 'Notes successfully added'];
|
||||
$data = ['code' => 1, 'msg' => 'Notes successfully updated'];
|
||||
}
|
||||
else{
|
||||
$data = ['code' => 3, 'msg' => 'Your request could not be handled at this time'];
|
||||
|
||||
Reference in New Issue
Block a user