51 lines
1.0 KiB
PHP
51 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\EggPrice;
|
|
use App\Models\Unit;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class EggPriceSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$unit = Unit::first() ?? Unit::factory()->create([
|
|
'name' => 'Kilogram',
|
|
'alias' => 'kg',
|
|
]);
|
|
|
|
$defaults = [
|
|
[
|
|
'name' => 'Ecer',
|
|
'price' => 2800,
|
|
],
|
|
[
|
|
'name' => 'Grosir',
|
|
'price' => 2600,
|
|
],
|
|
[
|
|
'name' => 'Distributor',
|
|
'price' => 2500,
|
|
],
|
|
];
|
|
|
|
foreach ($defaults as $data) {
|
|
EggPrice::firstOrCreate(
|
|
[
|
|
'name' => $data['name'],
|
|
'unit_id' => $unit->id,
|
|
],
|
|
[
|
|
'price' => $data['price'],
|
|
]
|
|
);
|
|
}
|
|
|
|
EggPrice::factory()->count(5)->create();
|
|
}
|
|
}
|