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

getCustomerFiles   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 25
ccs 13
cts 13
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 10 2
A getAllFiles() 0 11 1
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