Completed
Push — master ( f24edd...b4a558 )
by wen
03:13
created

PermissionsTableSeeder::insertPerm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
cc 1
eloc 18
nc 1
nop 6
1
<?php
2
3
use Illuminate\Database\Seeder;
4
5
class PermissionsTableSeeder extends Seeder
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
    public function run()
8
    {
9
        $this->storePermission('view_admin', '访问后台');
10
        $this->storePermission('manage_log', '管理操作日志');
11
12
        $this->storePermission('view_user', '查看用户');
13
        $this->storePermission('create_user', '创建用户');
14
        $this->storePermission('edit_user', '编辑用户');
15
        $this->storePermission('delete_user', '删除用户');
16
17
        $this->storePermission('view_role', '查看角色');
18
        $this->storePermission('create_role', '创建角色');
19
        $this->storePermission('edit_role', '编辑角色');
20
        $this->storePermission('delete_role', '删除角色');
21
22
        $this->storePermission('view_permission', '查看权限');
23
        $this->storePermission('create_permission', '创建权限');
24
        $this->storePermission('edit_permission', '编辑权限');
25
        $this->storePermission('delete_permission', '删除权限');
26
27
        $this->storePermission('admin.system.menu', '菜单');
28
    }
29
30
    private function storePermission($name, $displayName, $description = '')
31
    {
32
        $permissionModelName = config('admin.permission');
33
        $permission          = new $permissionModelName();
34
35
        $permission->display_name = $displayName;
36
        $permission->name         = $name;
37
        $permission->description  = $description;
38
        $permission->save();
39
40
        return $permission;
41
    }
42
}
43