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

GetDeletedItemsController::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 15
rs 10
ccs 6
cts 6
cp 1
cc 1
nc 1
nop 1
crap 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