Completed
Push — master ( d0984d...8e3192 )
by Jeremy
10:29 queued 05:27
created

LaravelpermissionsDeletedController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
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 LaravelpermissionsDeletedController extends Controller
11
{
12
    use RolesUsageAuthTrait;
13
    use RolesAndPermissionsHelpersTrait;
0 ignored issues
show
introduced by
The trait jeremykenedy\LaravelRole...PermissionsHelpersTrait requires some properties which are not provided by jeremykenedy\LaravelRole...ssionsDeletedController: $role_id, $user_id, $id, $roles, $permission_id
Loading history...
14
15
    /**
16
     * Show the deleted permission items.
17
     *
18
     * @return \Illuminate\Http\Response
19
     */
20
    public function index()
21
    {
22
        $deletedPermissions = $this->getDeletedPermissions()->get();
23
        $data = [
24
            'deletedPermissions' => $deletedPermissions,
25
        ];
26
27
        return view('laravelroles::laravelroles.crud.permissions.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->getDeletedPermissionAndDetails($id);
40
        $typeDeleted = 'deleted';
41
42
        return view('laravelroles::laravelroles.crud.permissions.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 permissions.
47
     *
48
     * @param \Illuminate\Http\Request $request The request
49
     *
50
     * @return \Illuminate\Http\Response
51
     */
52
    public function restoreAllDeletedPermissions(Request $request)
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

52
    public function restoreAllDeletedPermissions(/** @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
        $deletedPermissions = $this->restoreAllTheDeletedPermissions();
55
56
        if ($deletedPermissions['status'] === 'success') {
57
            return redirect()->route('laravelroles::roles.index')
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...Permissions['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.successRestoredAllPermissions', $deletedPermissions['count'], ['count' => $deletedPermissions['count']]));
59
        }
60
61
        return redirect()->route('laravelroles::roles.index')
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...toringAllPermissions')) 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.errorRestoringAllPermissions'));
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 restorePermission(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

73
    public function restorePermission(/** @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
        $permission = $this->restoreDeletedPermission($id);
76
77
        return redirect()->route('laravelroles::roles.index')
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...=> $permission->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.successRestoredPermission', ['permission' => $permission->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 destroyAllDeletedPermissions(Request $request)
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

88
    public function destroyAllDeletedPermissions(/** @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
        $deletedPermissions = $this->destroyAllTheDeletedPermissions();
91
92
        if ($deletedPermissions['status'] === 'success') {
93
            return redirect()->route('laravelroles::roles.index')
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...Permissions['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.successDestroyedAllPermissions', $deletedPermissions['count'], ['count' => $deletedPermissions['count']]));
95
        }
96
97
        return redirect()->route('laravelroles::roles.index')
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...royingAllPermissions')) 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.errorDestroyingAllPermissions'));
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
        $permission = $this->destroyPermission($id);
111
112
        return redirect()->route('laravelroles::roles.index')
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...=> $permission->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.successDestroyedPermission', ['permission' => $permission->name]));
114
    }
115
}
116