Test Failed
Push — dev5a ( 276986...e86993 )
by Ron
08:40
created

CustomerNotesController::store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
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