forked from TFMM/silent-auction
Add seeders and factories for all models
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\CarShowWinner;
|
||||
use App\Models\Vehicles;
|
||||
use App\Models\CarShowCategory;
|
||||
|
||||
class CarShowWinnerTableSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$categories = CarShowCategory::all();
|
||||
$vehicles = Vehicles::all();
|
||||
|
||||
foreach ($categories as $category) {
|
||||
for ($i = 1; $i <= 3; $i++) {
|
||||
factory(CarShowWinner::class)->create([
|
||||
'category' => $category->id,
|
||||
'vehicle' => $vehicles->random()->id,
|
||||
'place' => $i,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user