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

BreakCustomerLinkController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 5
c 1
b 0
f 0
dl 0
loc 12
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 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