Completed
Branch master (585519)
by Jeremy
40:45 queued 37:23
created

Http/Controllers/LaravelRolesDeletedController.php (12 issues)

1
<?php
2
3
namespace jeremykenedy\LaravelRoles\App\Http\Controllers;
4
5
use App\Http\Controllers\Controller;
6
use Illuminate\Http\Request;
7
use jeremykenedy\LaravelRoles\Traits\RolesAndPermissionsHelpersTrait;
8
use jeremykenedy\LaravelRoles\Traits\RolesUsageAuthTrait;
9
10
class LaravelRolesDeletedController extends Controller
11
{
12
    use RolesAndPermissionsHelpersTrait;
0 ignored issues
show
The trait jeremykenedy\LaravelRole...PermissionsHelpersTrait requires some properties which are not provided by jeremykenedy\LaravelRole...lRolesDeletedController: $role_id, $user_id, $id, $roles, $permission_id
Loading history...
13
    use RolesUsageAuthTrait;
14
15
    /**
16
     * Show the deleted role items.
17
     *
18
     * @return \Illuminate\Http\Response
19
     */
20
    public function index()
21
    {
22
        $deletedRoleItems = $this->getDeletedRoles()->get();
23
        $data = [
24
            'deletedRoleItems' => $deletedRoleItems,
25
        ];
26
27
        return view('laravelroles::laravelroles.crud.roles.deleted.index', $data);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('laravelrole....deleted.index', $data) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
28
    }
29
30
    /**
31
     * Display the specified resource.
32
     *
33
     * @param int $id
34
     *
35
     * @return \Illuminate\Http\Response
36
     */
37
    public function show($id)
38
    {
39
        $item = $this->getDeletedRole($id);
40
        $typeDeleted = 'deleted';
41
42
        return view('laravelroles::laravelroles.crud.roles.show', compact('item', 'typeDeleted'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('laravelrole...'item', 'typeDeleted')) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
43
    }
44
45
    /**
46
     * Dashbaord Method to restore all deleted roles.
47
     *
48
     * @param \Illuminate\Http\Request $request The request
49
     *
50
     * @return \Illuminate\Http\Response
51
     */
52
    public function restoreAllDeletedRoles(Request $request)
0 ignored issues
show
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

52
    public function restoreAllDeletedRoles(/** @scrutinizer ignore-unused */ Request $request)

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...
53
    {
54
        $deletedRoles = $this->restoreAllTheDeletedRoles();
55
56
        if ($deletedRoles['status'] === 'success') {
57
            return redirect()->route('laravelroles::roles.index')
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...eletedRoles['count']))) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
58
                        ->with('success', trans_choice('laravelroles::laravelroles.flash-messages.successRestoredAllRoles', $deletedRoles['count'], ['count' => $deletedRoles['count']]));
59
        }
60
61
        return redirect()->route('laravelroles::roles.index')
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...rorRestoringAllRoles')) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
62
                    ->with('error', trans('laravelroles::laravelroles.flash-messages.errorRestoringAllRoles'));
63
    }
64
65
    /**
66
     * Restore the specified resource in storage.
67
     *
68
     * @param \Illuminate\Http\Request $request
69
     * @param int                      $id
70
     *
71
     * @return \Illuminate\Http\Response
72
     */
73
    public function restoreRole(Request $request, $id)
0 ignored issues
show
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

73
    public function restoreRole(/** @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...
74
    {
75
        $role = $this->restoreDeletedRole($id);
76
77
        return redirect()->route('laravelroles::roles.index')
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...role' => $role->name))) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
78
                    ->with('success', trans('laravelroles::laravelroles.flash-messages.successRestoredRole', ['role' => $role->name]));
79
    }
80
81
    /**
82
     * Destroy all the specified resource from storage.
83
     *
84
     * @param \Illuminate\Http\Request $request The request
85
     *
86
     * @return \Illuminate\Http\Response
87
     */
88
    public function destroyAllDeletedRoles(Request $request)
0 ignored issues
show
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

88
    public function destroyAllDeletedRoles(/** @scrutinizer ignore-unused */ Request $request)

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...
89
    {
90
        $deletedRoles = $this->destroyAllTheDeletedRoles();
91
92
        if ($deletedRoles['status'] === 'success') {
93
            return redirect()->route('laravelroles::roles.index')
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...eletedRoles['count']))) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
94
                        ->with('success', trans_choice('laravelroles::laravelroles.flash-messages.successDestroyedAllRoles', $deletedRoles['count'], ['count' => $deletedRoles['count']]));
95
        }
96
97
        return redirect()->route('laravelroles::roles.index')
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...orDestroyingAllRoles')) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
98
                    ->with('error', trans('laravelroles::laravelroles.flash-messages.errorDestroyingAllRoles'));
99
    }
100
101
    /**
102
     * Remove the specified resource from storage.
103
     *
104
     * @param int $id
105
     *
106
     * @return \Illuminate\Http\Response
107
     */
108
    public function destroy($id)
109
    {
110
        $role = $this->destroyRole($id);
111
112
        return redirect()->route('laravelroles::roles.index')
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...role' => $role->name))) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
113
                    ->with('success', trans('laravelroles::laravelroles.flash-messages.successDestroyedRole', ['role' => $role->name]));
114
    }
115
}
116