Passed
Push — dev5 ( 1d5fd3...2b65af )
by Ron
08:51
created

CustomerNotesController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 33
ccs 14
cts 14
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A show() 0 3 1
A store() 0 4 1
A destroy() 0 4 1
A update() 0 4 1
1
<?php
2
3
namespace App\Http\Controllers\Customers;
4
5
use App\Http\Controllers\Controller;
6
7
use App\Domains\Customers\GetCustomerNotes;
8
use App\Domains\Customers\SetCustomerNotes;
9
10
use App\Http\Requests\CustomerNewNoteRequest;
11
use App\Http\Requests\CustomerEditNoteRequest;
12
13
class CustomerNotesController extends Controller
14
{
15
16 26
    public function __construct()
17
    {
18 26
        $this->middleware('auth');
19 26
    }
20
21
    //  Store a new customer note
22 4
    public function store(CustomerNewNoteRequest $request)
23
    {
24 4
        (new SetCustomerNotes($request->cust_id))->createNote($request);
25 4
        return response()->json(['success' => true]);
26
    }
27
28
    //  Get the customer notes
29 4
    public function show($id)
30
    {
31 4
        return (new GetCustomerNotes($id))->execute();
32
    }
33
34
    //  Update a customer note
35 4
    public function update(CustomerEditNoteRequest $request, $id)
36
    {
37 4
        (new SetCustomerNotes($request->cust_id))->updateNote($request, $id);
38 4
        return response()->json(['success' => true]);
39
    }
40
41
    //  Delete a customer note
42 2
    public function destroy($id)
43
    {
44 2
        (new SetCustomerNotes($id))->deleteNote($id);
45 2
        return response()->json(['success' => true]);
46
    }
47
}
48