PermissionController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 8 1
A create() 0 4 1
A store() 0 17 1
A datatable() 0 12 1
1
<?php
2
3
namespace Devfaysal\LaravelAdmin\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use Yajra\DataTables\DataTables;
7
use Illuminate\Support\Facades\Session;
8
use Spatie\Permission\Models\Permission;
9
10
class PermissionController extends Controller
11
{
12
    public function index()
13
    {
14
        $permissions = Permission::all();
15
16
        return view('laravel-admin::permissions.index', [
17
            'permissions' => $permissions
18
        ]);
19
    }
20
21
    public function create()
22
    {
23
        return view('laravel-admin::permissions.create');
24
    }
25
26
    public function store(Request $request)
27
    {
28
        $request->validate([
0 ignored issues
show
Bug introduced by
The call to validate() misses a required argument $...$params.

This check looks for function calls that miss required arguments.

Loading history...
29
            'name' => 'required|unique:permissions',
30
        ]);
31
32
        Permission::create([
33
                'name' => $request->name,
34
                'guard_name' => $request->guard_name
35
            ]);
36
        
37
        Session::flash('message', 'Permission created Successfully!!'); 
38
        Session::flash('alert-class', 'alert-success');
39
40
        return redirect('/admin/permissions');
41
        
42
    }
43
44
    public function datatable()
45
    {
46
        $permissions = Permission::all();
47
48
        return DataTables::of($permissions)
49
            ->addColumn('action', function($role) {
0 ignored issues
show
Unused Code introduced by
The parameter $role is not used and could be removed.

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

Loading history...
50
                $string  = '<a class="btn btn-sm btn-oval btn-info" href="#">Edit</a>';
51
                $string .= ' <a class="btn btn-sm btn-oval btn-primary" href="#">Show</a>';
52
                return $string;
53
            })
54
            ->make(true);
55
    }
56
}
57