File tree Expand file tree Collapse file tree 3 files changed +73
-1
lines changed Expand file tree Collapse file tree 3 files changed +73
-1
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,8 @@ public function run()
16
16
// \App\Models\User::factory(10)->create();
17
17
18
18
$ this ->call ([
19
- UserSeeder::class,
20
19
RoleSeeder::class,
20
+ UserSeeder::class,
21
21
]);
22
22
}
23
23
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Database \Seeders ;
4
+
5
+ use Illuminate \Database \Seeder ;
6
+ use App \Models \Role ;
7
+
8
+ class RoleSeeder extends Seeder
9
+ {
10
+ /**
11
+ * Run the database seeds.
12
+ *
13
+ * @return void
14
+ */
15
+ public function run ()
16
+ {
17
+ Role::create ([
18
+ 'name ' => 'Administrator ' ,
19
+ ]);
20
+
21
+ Role::create ([
22
+ 'name ' => 'Employee ' ,
23
+ ]);
24
+
25
+ Role::create ([
26
+ 'name ' => 'Client ' ,
27
+ ]);
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Database \Seeders ;
4
+
5
+ use Illuminate \Database \Seeder ;
6
+ use Illuminate \Support \Facades \Hash ;
7
+ use App \Models \User ;
8
+ use App \Models \Role ;
9
+
10
+ class UserSeeder extends Seeder
11
+ {
12
+ /**
13
+ * Run the database seeds.
14
+ *
15
+ * @return void
16
+ */
17
+ public function run ()
18
+ {
19
+ $ administrator = User::create ([
20
+ 'name ' => 'Administrator ' ,
21
+ 'email ' => 'administrator@localhost.com ' ,
22
+ 'password ' => Hash::make ('password ' ),
23
+ ]);
24
+
25
+ $ administrator ->roles ()->sync ('1 ' );
26
+
27
+ $ employee = User::create ([
28
+ 'name ' => 'Employee ' ,
29
+ 'email ' => 'employee@localhost.com ' ,
30
+ 'password ' => Hash::make ('password ' ),
31
+ ]);
32
+
33
+ $ employee ->roles ()->sync ('2 ' );
34
+
35
+ $ client = User::create ([
36
+ 'name ' => 'Client ' ,
37
+ 'email ' => 'client@localhost.com ' ,
38
+ 'password ' => Hash::make ('password ' ),
39
+ ]);
40
+
41
+ $ client ->roles ()->sync ('3 ' );
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments