Passed
Push — dev5a ( e86993...328ab1 )
by Ron
10:15 queued 39s
created

getCustomerFiles::getAllFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 11
ccs 8
cts 8
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Domains\Customers;
4
5
use Illuminate\Support\Facades\Auth;
6
use Illuminate\Support\Facades\Log;
7
use App\CustomerFiles;
8
9
10
class getCustomerFiles extends GetCustomerDetails
11
{
12 6
    public function execute($custID)
13
    {
14 6
        $files = $this->getAllFiles($custID);
15
16 6
        if($parent = $this->getParentID($custID))
17
        {
18 2
            $files = $files->merge($this->getAllFiles($parent, true));
19
        }
20
21 6
        return $files;
22
    }
23
24 6
    protected function getAllFiles($custID, $shared = false)
25
    {
26 6
        return CustomerFiles::where('cust_id', $custID)
27
            ->when($shared, function($q)
28
            {
29 2
                $q->where('shared', 1);
30 6
            })
31 6
            ->with('Files')
32 6
            ->with('CustomerFileTypes')
33 6
            ->with('User')
34 6
            ->get();
35
    }
36
}
37