Test Setup Failed
Push — dev6 ( 81193f...01d104 )
by Ron
22:34
created

DisabledUserController::destroy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 2
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Http\Controllers\User;
4
5
use Inertia\Inertia;
6
7
use App\Models\User;
8
use App\Http\Controllers\Controller;
9
10
use Illuminate\Support\Facades\Log;
11
12
class DisabledUserController extends Controller
13
{
14
    /**
15
     *  Show all disabled users
16
     */
17
    public function index()
18
    {
19
        $this->authorize('create', User::class);
20
21
        return Inertia::render('User/disabled', [
22
            'user_list' => User::onlyTrashed()->get()->makeVisible(['user_id', 'deleted_at'])->makeHidden(['first_name', 'last_name', 'initials']),
23
        ]);
24
    }
25
26
    /**
27
     *  Restore a user who has been deactivated
28
     */
29
    public function update($id)
30
    {
31
        $this->authorize('restore', User::withTrashed()->where('user_id', $id)->first());
32
33
        $user = User::withTrashed()->where('user_id', $id)->first();
34
        $user->restore();
35
36
        Log::stack(['auth', 'user'])->notice('User '.$user->username.' has been reactivated');
37
        return back()->with(['message' => 'User '.$user->full_name.' has been successfully reactivated', 'type' => 'success']);
38
    }
39
40
    /**
41
     *  Perminately delete a user and all of their information
42
     */
43
    // public function destroy($id)
44
    // {
45
    //     //
46
    // }
47
}
48