DisableUserController::store()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
nc 2
nop 2
dl 0
loc 15
c 0
b 0
f 0
cc 2
rs 10
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