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

GetCustomerNotes::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 2
b 0
f 0
nc 2
nop 1
dl 0
loc 10
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 GetCustomerNotes extends GetCustomerDetails
11
{
12
    public function execute($custID)
13
    {
14
        $notes = $this->getNotes($custID);
15
16
        if($parent = $this->getParentID($custID))
17
        {
18
            $notes = $notes->merge($this->getNotes($parent, true));
19
        }
20
21
        return $notes;
22
    }
23
24
    protected function getNotes($custID, $shared = false)
25
    {
26
        return CustomerNotes::where('cust_id', $custID)
27
            ->when($shared, function($q)
28
            {
29
                $q->where('shared', 1);
30
            })
31
            ->orderBy('urgent', 'DESC')
32
            ->get();
33
    }
34
}
35