DisableUserController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 17
c 0
b 0
f 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A store() 0 15 2
1
<?php
2
3
namespace Thinktomorrow\Chief\App\Http\Controllers\Back\Users;
4
5
use Illuminate\Http\Request;
6
use Thinktomorrow\Chief\Admin\Users\Application\DisableUser;
7
use Thinktomorrow\Chief\Admin\Users\User;
8
use Thinktomorrow\Chief\App\Http\Controllers\Controller;
9
10
class DisableUserController extends Controller
11
{
12
    public function store(Request $request, $id)
13
    {
14
        $this->authorize('disable-user');
15
16
        if (chiefAdmin()->id == $id) {
0 ignored issues
show
Bug introduced by
Accessing id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
17
            return redirect()->back()
18
                ->with('messages.error', 'U kan uzelf niet blokkeren.');
19
        }
20
21
        $user = User::findOrFail($id);
22
23
        app(DisableUser::class)->handle($user);
24
25
        return redirect()->route('chief.back.users.index')
26
            ->with('messages.success', 'De gebruikersaccount is geblokkeerd met onmiddellijke ingang.');
27
    }
28
}
29