-
database/seeders/DatabaseSeeder.php
Open in GitHubuse Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder { public function run() { // Collaborator::factory()->times(2)->create()->each(function ($collaborator) use (&$packages) { $collaborator->authoredPackages()->save(next($packages)); $collaborator->authoredPackages()->save(next($packages)); }); $users = User::all(); // Give each of our main packages a jillion ratings Package::all()->each(function ($package) use ($users) { $users->shuffle(); $users->take(50)->each(function ($user) use ($package) { $user->ratePackage($package->id, rand(1, 15) / 3); }); }); $tags = Tag::all(); Package::factory()->times(400)->create(); Package::all()->each(function ($package) use ($tags, $users) { $package->tags()->attach($tags->random()->take(3)->get()); $users->random()->ratePackage($package->id, rand(1, 15) / 3); $users->random()->ratePackage($package->id, rand(1, 15) / 3); $users->random()->ratePackage($package->id, rand(1, 15) / 3); }); } }