Test Failed
Push — dev6 ( 033ddc...06d260 )
by Ron
20:10
created

BreakCustomerLinkController::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Http\Controllers\Customers;
4
5
use App\Models\Customer;
6
use App\Http\Controllers\Controller;
7
8
use Illuminate\Support\Facades\Log;
9
use Illuminate\Support\Facades\Auth;
10
11
class BreakCustomerLinkController extends Controller
12
{
13
    /**
14
     *  Break the link between the customer and its parent
15
     */
16
    public function __invoke($cust_id)
17
    {
18
        $this->authorize('manage', Customer::class);
19
        Customer::findOrFail($cust_id)->update(['parent_id' => null]);
20
21
        Log::channel('cust')->notice('Customer Link broken for Customer ID '.$cust_id.' by '.Auth::user()->username);
1 ignored issue
show
Bug introduced by
Accessing username on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
22
        return back()->with(['message' => 'Customer Link Broken', 'type' => 'warning']);
23
    }
24
}
25