1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Customers; |
4
|
|
|
|
5
|
|
|
use App\Domains\Customers\GetCustomerNotes; |
6
|
|
|
use App\Domains\Customers\SetCustomerNotes; |
7
|
|
|
use App\Http\Controllers\Controller; |
8
|
|
|
use App\Http\Requests\Customers\CustomerNoteRequest; |
9
|
|
|
use Illuminate\Http\Request; |
10
|
|
|
use Illuminate\Support\Facades\Auth; |
11
|
|
|
use Illuminate\Support\Facades\Log; |
12
|
|
|
|
13
|
|
|
class CustomerNotesController extends Controller |
14
|
|
|
{ |
15
|
|
|
// Create a new customer note |
16
|
|
|
public function store(CustomerNoteRequest $request) |
17
|
|
|
{ |
18
|
|
|
(new SetCustomerNotes)->createNewNote($request, $request->cust_id, Auth::user()->user_id); |
19
|
|
|
Log::info('A new note has been created for Customer ID '.$request->cust_id.' by '.Auth::user()->full_name.'. Data - ', $request->toArray()); |
20
|
|
|
return response()->json(['success' => true]); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
// Get all notes for a customer |
24
|
|
|
public function show($id) |
25
|
|
|
{ |
26
|
|
|
return (new GetCustomerNotes)->execute($id); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
// Update an existing note |
30
|
|
|
public function update(Request $request, $id) |
31
|
|
|
{ |
32
|
|
|
(new SetCustomerNotes)->updateNote($request, $request->cust_id, $id); |
33
|
|
|
Log::info('Customer Note ID '.$id.' updated by '.Auth::user()->full_name); |
34
|
|
|
return response()->json(['success' => true]); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
// Delete an existing note |
38
|
|
|
public function destroy($id) |
39
|
|
|
{ |
40
|
|
|
(new SetCustomerNotes)->deleteNote($id); |
41
|
|
|
Log::info('Customer Note ID '.$id.' deleted by '.Auth::user()->full_name); |
42
|
|
|
return response()->json(['success' => true]); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|