Test Failed
Branch dev5a (e86993)
by Ron
07:40
created

CustomerNotesController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 30
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A show() 0 3 1
A store() 0 5 1
A destroy() 0 5 1
A update() 0 5 1
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