Completed
Push — master ( f9866e...fa91dc )
by Song
02:51
created

src/Auth/Database/AdminTablesSeeder.php (4 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Encore\Admin\Auth\Database;
4
5
use Illuminate\Database\Seeder;
6
7
class AdminTablesSeeder extends Seeder
8
{
9
    /**
10
     * Run the database seeds.
11
     *
12
     * @return void
13
     */
14
    public function run()
15
    {
16
        // create a user.
17
        Administrator::truncate();
18
        Administrator::create([
0 ignored issues
show
The method create() does not exist on Encore\Admin\Auth\Database\Administrator. Did you maybe mean created()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
19
            'username' => 'admin',
20
            'password' => bcrypt('admin'),
21
            'name'     => 'Administrator',
22
        ]);
23
24
        // create a role.
25
        Role::truncate();
26
        Role::create([
0 ignored issues
show
The method create() does not exist on Encore\Admin\Auth\Database\Role. Did you maybe mean created()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
27
            'name' => 'Administrator',
28
            'slug' => 'administrator',
29
        ]);
30
31
        // add role to user.
32
        Administrator::first()->roles()->save(Role::first());
33
34
        //create a permission
35
        Permission::truncate();
36
        Permission::insert([
0 ignored issues
show
The method insert() does not exist on Encore\Admin\Auth\Database\Permission. Did you maybe mean insertAndSetId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
37
            [
38
                'name'        => 'All permission',
39
                'slug'        => '*',
40
                'http_method' => '',
41
                'http_path'   => '*',
42
            ],
43
            [
44
                'name'        => 'Dashboard',
45
                'slug'        => 'dashboard',
46
                'http_method' => 'GET',
47
                'http_path'   => '/',
48
            ],
49
            [
50
                'name'        => 'Login',
51
                'slug'        => 'auth.login',
52
                'http_method' => '',
53
                'http_path'   => "/auth/login\r\n/auth/logout",
54
            ],
55
            [
56
                'name'        => 'User setting',
57
                'slug'        => 'auth.setting',
58
                'http_method' => 'GET,PUT',
59
                'http_path'   => '/auth/setting',
60
            ],
61
            [
62
                'name'        => 'Auth management',
63
                'slug'        => 'auth.management',
64
                'http_method' => '',
65
                'http_path'   => "/auth/roles\r\n/auth/permissions\r\n/auth/menu\r\n/auth/logs",
66
            ],
67
        ]);
68
69
        Role::first()->permissions()->save(Permission::first());
70
71
        // add default menus.
72
        Menu::truncate();
73
        Menu::insert([
0 ignored issues
show
The method insert() does not exist on Encore\Admin\Auth\Database\Menu. Did you maybe mean insertAndSetId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
74
            [
75
                'parent_id' => 0,
76
                'order'     => 1,
77
                'title'     => 'Index',
78
                'icon'      => 'fa-bar-chart',
79
                'uri'       => '/',
80
            ],
81
            [
82
                'parent_id' => 0,
83
                'order'     => 2,
84
                'title'     => 'Admin',
85
                'icon'      => 'fa-tasks',
86
                'uri'       => '',
87
            ],
88
            [
89
                'parent_id' => 2,
90
                'order'     => 3,
91
                'title'     => 'Users',
92
                'icon'      => 'fa-users',
93
                'uri'       => 'auth/users',
94
            ],
95
            [
96
                'parent_id' => 2,
97
                'order'     => 4,
98
                'title'     => 'Roles',
99
                'icon'      => 'fa-user',
100
                'uri'       => 'auth/roles',
101
            ],
102
            [
103
                'parent_id' => 2,
104
                'order'     => 5,
105
                'title'     => 'Permission',
106
                'icon'      => 'fa-ban',
107
                'uri'       => 'auth/permissions',
108
            ],
109
            [
110
                'parent_id' => 2,
111
                'order'     => 6,
112
                'title'     => 'Menu',
113
                'icon'      => 'fa-bars',
114
                'uri'       => 'auth/menu',
115
            ],
116
            [
117
                'parent_id' => 2,
118
                'order'     => 7,
119
                'title'     => 'Operation log',
120
                'icon'      => 'fa-history',
121
                'uri'       => 'auth/logs',
122
            ],
123
        ]);
124
125
        // add role to menu.
126
        Menu::find(2)->roles()->save(Role::first());
127
    }
128
}
129