GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SoftDeletesController   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 85
rs 10
c 0
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getDeletedUser() 0 8 2
A __construct() 0 3 1
A update() 0 6 1
A index() 0 6 1
A show() 0 5 1
A destroy() 0 6 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Models\User;
6
use Auth;
7
use Illuminate\Http\Request;
8
use jeremykenedy\LaravelRoles\Models\Role;
9
10
class SoftDeletesController extends Controller
11
{
12
    /**
13
     * Create a new controller instance.
14
     *
15
     * @return void
16
     */
17
    public function __construct()
18
    {
19
        $this->middleware('auth');
20
    }
21
22
    /**
23
     * Get Soft Deleted User.
24
     *
25
     * @param int $id
26
     *
27
     * @return \Illuminate\Http\Response
28
     */
29
    public static function getDeletedUser($id)
30
    {
31
        $user = User::onlyTrashed()->where('id', $id)->get();
32
        if (count($user) != 1) {
33
            return redirect('/users/deleted/')->with('error', trans('usersmanagement.errorUserNotFound'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect('/users/...nt.errorUserNotFound')) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
34
        }
35
36
        return $user[0];
37
    }
38
39
    /**
40
     * Display a listing of the resource.
41
     *
42
     * @return \Illuminate\Http\Response
43
     */
44
    public function index()
45
    {
46
        $users = User::onlyTrashed()->get();
47
        $roles = Role::all();
48
49
        return View('usersmanagement.show-deleted-users', compact('users', 'roles'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return View('usersmanage...pact('users', 'roles')) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
50
    }
51
52
    /**
53
     * Display the specified resource.
54
     *
55
     * @param int $id
56
     *
57
     * @return \Illuminate\Http\Response
58
     */
59
    public function show($id)
60
    {
61
        $user = self::getDeletedUser($id);
62
63
        return view('usersmanagement.show-deleted-user')->withUser($user);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('usersmanage...user')->withUser($user) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
64
    }
65
66
    /**
67
     * Update the specified resource in storage.
68
     *
69
     * @param \Illuminate\Http\Request $request
70
     * @param int                      $id
71
     *
72
     * @return \Illuminate\Http\Response
73
     */
74
    public function update(Request $request, $id)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

74
    public function update(/** @scrutinizer ignore-unused */ Request $request, $id)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
75
    {
76
        $user = self::getDeletedUser($id);
77
        $user->restore();
78
79
        return redirect('/users/')->with('success', trans('usersmanagement.successRestore'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect('/users/...ement.successRestore')) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
80
    }
81
82
    /**
83
     * Remove the specified resource from storage.
84
     *
85
     * @param int $id
86
     *
87
     * @return \Illuminate\Http\Response
88
     */
89
    public function destroy($id)
90
    {
91
        $user = self::getDeletedUser($id);
92
        $user->forceDelete();
93
94
        return redirect('/users/deleted/')->with('success', trans('usersmanagement.successDestroy'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect('/users/...ement.successDestroy')) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
95
    }
96
}
97