|
@@ -1,5 +1,9 @@
|
|
|
<?php
|
|
|
|
|
|
+use Carbon\Carbon;
|
|
|
+use App\Location;
|
|
|
+use App\Role;
|
|
|
+use App\User;
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
|
|
class DatabaseSeeder extends Seeder
|
|
@@ -11,6 +15,20 @@ class DatabaseSeeder extends Seeder
|
|
|
*/
|
|
|
public function run()
|
|
|
{
|
|
|
- // $this->call(UsersTableSeeder::class);
|
|
|
+
|
|
|
+
|
|
|
+ factory(Role::class, 1)->create([
|
|
|
+ 'created_at' => Carbon::now()->subDays(10),
|
|
|
+ ])->each(function(Role $role) {
|
|
|
+ $role->users()->saveMany(
|
|
|
+ factory(User::class, 10)->create([
|
|
|
+ 'role_id' => $role->id,
|
|
|
+ 'created_at' => Carbon::now()->subDays(10)
|
|
|
+ ])->each(function (User $user) {
|
|
|
+ $user->locations()->saveMany(
|
|
|
+ factory(Location::class, random_int(20, 50))->make());
|
|
|
+ })
|
|
|
+ );
|
|
|
+ });
|
|
|
}
|
|
|
}
|