1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Database\Seeder; |
4
|
|
|
use Illuminate\Support\Facades\DB; |
5
|
|
|
use Illuminate\Support\Str; |
6
|
|
|
|
7
|
|
|
class UsersTableSeeder extends Seeder |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Run the database seeds. |
11
|
|
|
* |
12
|
|
|
* @return void |
13
|
|
|
*/ |
14
|
|
|
public function run() |
15
|
|
|
{ |
16
|
|
|
$faker = Faker\Factory::create(); |
17
|
|
|
$now = \Carbon\Carbon::now(); |
18
|
|
|
|
19
|
|
|
DB::table('users')->insert([[ |
20
|
|
|
'id' => 1, |
21
|
|
|
'name' => $faker->name, |
22
|
|
|
'email' => $faker->safeEmail, |
23
|
|
|
'password' => bcrypt('secret'), |
24
|
|
|
'remember_token' => Str::random(10), |
25
|
|
|
'created_at' => $now, |
26
|
|
|
'updated_at' => $now, |
27
|
|
|
]]); |
28
|
|
|
|
29
|
|
|
DB::table('users')->insert([[ |
30
|
|
|
'id' => 2, |
31
|
|
|
'name' => $faker->name, |
32
|
|
|
'email' => $faker->safeEmail, |
33
|
|
|
'password' => bcrypt('secret'), |
34
|
|
|
'remember_token' => Str::random(10), |
35
|
|
|
'created_at' => $now, |
36
|
|
|
'updated_at' => $now, |
37
|
|
|
]]); |
38
|
|
|
|
39
|
|
|
DB::table('user_role')->insert([ |
40
|
|
|
'user_id' => 1, |
41
|
|
|
'role_id' => 1, |
42
|
|
|
]); |
43
|
|
|
|
44
|
|
|
DB::table('user_role')->insert([ |
45
|
|
|
'user_id' => 2, |
46
|
|
|
'role_id' => 1, |
47
|
|
|
]); |
48
|
|
|
DB::table('user_role')->insert([ |
49
|
|
|
'user_id' => 2, |
50
|
|
|
'role_id' => 2, |
51
|
|
|
]); |
52
|
|
|
|
53
|
|
|
DB::table('account_details')->insert([ |
54
|
|
|
'user_id' => 1, |
55
|
|
|
'nickname' => $faker->firstName(), |
56
|
|
|
'profile_picture' => $faker->imageUrl(), |
57
|
|
|
]); |
58
|
|
|
|
59
|
|
|
DB::table('addresses')->insert([ |
60
|
|
|
'account_details_id' => 1, |
61
|
|
|
'city' => $faker->city, |
62
|
|
|
'street' => $faker->streetName, |
63
|
|
|
'number' => $faker->randomDigitNotNull, |
64
|
|
|
]); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|