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

SetCustomerNotes::deleteNote()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace App\Domains\Customers;
4
5
use App\CustomerNotes;
6
use Illuminate\Support\Facades\Auth;
7
use Illuminate\Support\Facades\Log;
8
9
10
class SetCustomerNotes extends GetCustomerDetails
11
{
12
    public function createNewNote($request, $custID, $userID)
13
    {
14
        if($request->shared)
15
        {
16
            $parent = $this->getParentID($custID);
17
            if($parent)
18
            {
19
                $custID = $parent;
20
            }
21
        }
22
23
        CustomerNotes::create([
24
            'cust_id'     => $custID,
25
            'user_id'     => $userID,
26
            'shared'      => $request->shared,
27
            'urgent'      => $request->urgent,
28
            'subject'     => $request->subject,
29
            'description' => $request->description,
30
        ]);
31
32
        return true;
33
    }
34
35
    public function updateNote($request, $custID, $noteID)
36
    {
37
        if($request->shared)
38
        {
39
            $parent = $this->getParentID($custID);
40
            if($parent)
41
            {
42
                $custID = $parent;
43
            }
44
        }
45
46
        CustomerNotes::find($noteID)->update([
47
            'cust_id'     => $custID,
48
            'shared'      => $request->shared,
49
            'urgent'      => $request->urgent,
50
            'subject'     => $request->subject,
51
            'description' => $request->description,
52
        ]);
53
54
        return true;
55
    }
56
57
    public function deleteNote($noteID)
58
    {
59
        CustomerNotes::find($noteID)->delete();
60
        return true;
61
    }
62
}
63