12345678910111213141516171819202122232425262728293031323334 |
- <?php
- use Carbon\Carbon;
- use App\Location;
- use App\Role;
- use App\User;
- use Illuminate\Database\Seeder;
- class DatabaseSeeder extends Seeder
- {
- /**
- * Seed the application's database.
- *
- * @return void
- */
- public function run()
- {
- 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());
- })
- );
- });
- }
- }
|