65 lines
1.5 KiB
PHP
65 lines
1.5 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
|
|
{
|
|
$kgUnit = Unit::where('alias', 'kg')->first();
|
|
$butirUnit = Unit::where('alias', 'butir')->first();
|
|
|
|
$defaults = [
|
|
[
|
|
'name' => 'Ecer',
|
|
'price' => 28000,
|
|
'unit_id' => $kgUnit->id,
|
|
],
|
|
[
|
|
'name' => 'Grosir',
|
|
'price' => 26000,
|
|
'unit_id' => $kgUnit->id,
|
|
],
|
|
[
|
|
'name' => 'Distributor',
|
|
'price' => 25000,
|
|
'unit_id' => $kgUnit->id,
|
|
],
|
|
[
|
|
'name' => 'Ecer',
|
|
'price' => 2800,
|
|
'unit_id' => $butirUnit->id,
|
|
],
|
|
[
|
|
'name' => 'Grosir',
|
|
'price' => 2600,
|
|
'unit_id' => $butirUnit->id,
|
|
],
|
|
[
|
|
'name' => 'Distributor',
|
|
'price' => 2500,
|
|
'unit_id' => $butirUnit->id,
|
|
],
|
|
];
|
|
|
|
foreach ($defaults as $data) {
|
|
EggPrice::firstOrCreate(
|
|
[
|
|
'name' => $data['name'],
|
|
'unit_id' => $data['unit_id'],
|
|
],
|
|
[
|
|
'price' => $data['price'],
|
|
]
|
|
);
|
|
}
|
|
}
|
|
}
|