Passed
Push — dev6 ( 9c7079...72e99e )
by Ron
15:54
created

GetDeletedItemsController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
eloc 8
c 2
b 0
f 0
dl 0
loc 20
rs 10
ccs 6
cts 6
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 15 1
1
<?php
2
3
namespace App\Http\Controllers\Customers;
4
5
use App\Http\Controllers\Controller;
6
7
use App\Models\Customer;
8
use App\Models\CustomerFile;
9
use App\Models\CustomerNote;
10
use App\Models\CustomerContact;
11
use App\Models\CustomerEquipment;
12
13
class GetDeletedItemsController extends Controller
14
{
15
    /**
16
     * Get all items that have been soft deleted for the customer
17
     */
18
    public function __invoke($id)
19 2
    {
20
        $this->authorize('manage', Customer::class);
21 2
        $deleted = [];
22
23 1
        //  Get deleted Equipment
24
        $deleted['equipment'] = CustomerEquipment::where('cust_id', $id)->onlyTrashed()->get()->makeVisible('deleted_at');
25
        //  Get deleted Contacts
26 1
        $deleted['contacts'] = CustomerContact::where('cust_id', $id)->onlyTrashed()->get()->makeVisible('deleted_at');
27
        //  Get deleted Notes
28
        $deleted['notes'] = CustomerNote::where('cust_id', $id)->onlyTrashed()->get()->makeVisible('deleted_at');
29 1
        //  Get deleted files
30
        $deleted['files'] = CustomerFile::where('cust_id', $id)->onlyTrashed()->get()->makeVisible('deleted_at');
31
32 1
        return $deleted;
33
    }
34
}
35