Passed
Push — main ( 5e9128...7e664e )
by PRATIK
03:55
created

RoleController::changeModulePermission()   A

Complexity

Conditions 6
Paths 32

Size

Total Lines 30
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 17
nc 32
nop 1
dl 0
loc 30
rs 9.0777
c 0
b 0
f 0
1
<?php
2
3
namespace Pratiksh\Adminetic\Http\Controllers\Admin;
4
5
use App\Http\Controllers\Controller;
0 ignored issues
show
Bug introduced by
The type App\Http\Controllers\Controller was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Http\Request;
7
use Pratiksh\Adminetic\Contracts\RoleRepositoryInterface;
8
use Pratiksh\Adminetic\Http\Requests\RoleRequest;
9
use Pratiksh\Adminetic\Models\Admin\Permission;
10
use Pratiksh\Adminetic\Models\Admin\Role;
11
12
class RoleController extends Controller
13
{
14
    protected $roleRepositoryInterface;
15
16
    public function __construct(RoleRepositoryInterface $roleRepositoryInterface)
17
    {
18
        $this->roleRepositoryInterface = $roleRepositoryInterface;
19
        $this->authorizeResource(Role::class, 'role');
20
    }
21
22
    /**
23
     * Display a listing of the resource.
24
     *
25
     * @return \Illuminate\Http\Response
26
     */
27
    public function index()
28
    {
29
        return view('adminetic::admin.role.index', $this->roleRepositoryInterface->indexRole());
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('adminetic::...Interface->indexRole()) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
30
    }
31
32
    /**
33
     * Show the form for creating a new resource.
34
     *
35
     * @return \Illuminate\Http\Response
36
     */
37
    public function create()
38
    {
39
        return view('adminetic::admin.role.create');
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('adminetic::admin.role.create') returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
40
    }
41
42
    /**
43
     * Store a newly created resource in storage.
44
     *
45
     * @param  \Pratiksh\Adminetic\Http\Requests\RoleRequest  $request
46
     * @return \Illuminate\Http\Response
47
     */
48
    public function store(RoleRequest $request)
49
    {
50
        $this->roleRepositoryInterface->storeRole($request);
51
52
        return redirect(adminRedirectRoute('role'))->withSuccess('Role Created Successfully.');
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect(adminRed...Created Successfully.') also could return the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
53
    }
54
55
    /**
56
     * Display the specified resource.
57
     *
58
     * @param  \Pratiksh\Adminetic\Models\Admin\Role  $role
59
     * @return \Illuminate\Http\Response
60
     */
61
    public function show(Role $role)
62
    {
63
        return view('adminetic::admin.role.show', $this->roleRepositoryInterface->showRole($role));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('adminetic::...rface->showRole($role)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
64
    }
65
66
    /**
67
     * Show the form for editing the specified resource.
68
     *
69
     * @param  \Pratiksh\Adminetic\Models\Admin\Role  $role
70
     * @return \Illuminate\Http\Response
71
     */
72
    public function edit(Role $role)
73
    {
74
        return view('adminetic::admin.role.edit', $this->roleRepositoryInterface->editRole($role));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('adminetic::...rface->editRole($role)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
75
    }
76
77
    /**
78
     * Update the specified resource in storage.
79
     *
80
     * @param  \Pratiksh\Adminetic\Http\Requests\RoleRequest  $request
81
     * @param  \Pratiksh\Adminetic\Models\Admin\Role  $role
82
     * @return \Illuminate\Http\Response
83
     */
84
    public function update(RoleRequest $request, Role $role)
85
    {
86
        $this->roleRepositoryInterface->updateRole($request, $role);
87
88
        return redirect(adminRedirectRoute('role'))->withInfo('Role Updated Successfully.');
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect(adminRed...Updated Successfully.') also could return the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
89
    }
90
91
    /**
92
     * Remove the specified resource from storage.
93
     *
94
     * @param  \Pratiksh\Adminetic\Models\Admin\Role  $role
95
     * @return \Illuminate\Http\Response
96
     */
97
    public function destroy(Role $role)
98
    {
99
        $this->roleRepositoryInterface->destroyRole($role);
100
101
        return redirect(adminRedirectRoute('role'))->withFail('Role Deleted Successfully.');
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect(adminRed...Deleted Successfully.') also could return the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
102
    }
103
}
104