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()); }) ); }); } }