From 0210d08477e6b53bd3220d81ce6b2882aba0ce6d Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Thu, 26 Feb 2026 07:56:22 +0700 Subject: [PATCH] feat: Remove EggPrice resource and related components from the application --- .../DelayedGoods/Schemas/DelayedGoodForm.php | 114 ++++------ .../Resources/Manage/Orders/OrderResource.php | 202 +++++++----------- .../Master/EggPrices/EggPriceResource.php | 134 ------------ .../EggPrices/Pages/ManageEggPrices.php | 31 --- app/Models/EggPrice.php | 27 --- app/Policies/EggPricePolicy.php | 69 ------ database/factories/EggPriceFactory.php | 26 --- database/factories/OrderFactory.php | 8 +- ...6_02_18_000006_create_egg_prices_table.php | 26 --- database/seeders/DatabaseSeeder.php | 1 - database/seeders/EggPriceSeeder.php | 64 ------ 11 files changed, 129 insertions(+), 573 deletions(-) delete mode 100644 app/Filament/Resources/Master/EggPrices/EggPriceResource.php delete mode 100644 app/Filament/Resources/Master/EggPrices/Pages/ManageEggPrices.php delete mode 100644 app/Models/EggPrice.php delete mode 100644 app/Policies/EggPricePolicy.php delete mode 100644 database/factories/EggPriceFactory.php delete mode 100644 database/migrations/2026_02_18_000006_create_egg_prices_table.php delete mode 100644 database/seeders/EggPriceSeeder.php diff --git a/app/Filament/Resources/DelayedGoods/Schemas/DelayedGoodForm.php b/app/Filament/Resources/DelayedGoods/Schemas/DelayedGoodForm.php index dcac87e..088a7b3 100644 --- a/app/Filament/Resources/DelayedGoods/Schemas/DelayedGoodForm.php +++ b/app/Filament/Resources/DelayedGoods/Schemas/DelayedGoodForm.php @@ -2,9 +2,7 @@ namespace App\Filament\Resources\DelayedGoods\Schemas; -use App\Models\EggPrice; use Filament\Forms\Components\DatePicker; -use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Select; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; @@ -23,56 +21,24 @@ public static function configure(Schema $schema): Schema $set('total_amount', number_format($totalAmount, 0, ',', '.')); }; - return $schema->components([ - Hidden::make('unit_id') - ->required(), + $recalculateRemaining = function (callable $get, callable $set): void { + $paidAmount = (int) str()->replace('.', '', (string) ($get('paid_amount') ?? 0)); + $totalAmount = (int) str()->replace('.', '', (string) ($get('total_amount') ?? 0)); + $remaining = max(0, $totalAmount - $paidAmount); + + $set('remaining_amount', number_format($remaining, 0, ',', '.')); + }; + + return $schema->components([ Grid::make(2) ->schema([ - Select::make('egg_price_id') - ->label('Harga Telur') - ->options( - EggPrice::query() - ->with('unit') - ->orderBy('name') - ->get() - ->mapWithKeys(function ($item) { - return [$item->id => $item->name.' ('.($item->unit?->alias ?? '-').')']; - }) - ) - ->searchable() - ->preload() + DatePicker::make('stored_date') + ->label('Tanggal Penyimpanan') + ->default(now()) + ->required() ->native(false) - ->live() - ->afterStateHydrated(function ($state, callable $set, callable $get, $record): void { - if ($record && ! $state) { - $eggPrice = EggPrice::where('unit_id', $record->unit_id) - ->where('price', $record->unit_price) - ->first(); - - if ($eggPrice) { - $set('egg_price_id', $eggPrice->id); - } - } - }) - ->afterStateUpdated(function ($state, callable $set, callable $get) use ($recalculateTotal): void { - if (! $state) { - $set('unit_price', 0); - $set('unit_id', null); - $recalculateTotal($get, $set); - - return; - } - - $price = EggPrice::with('unit')->find($state); - - $set('unit_price', number_format($price?->price ?? 0, 0, ',', '.')); - $set('unit_id', $price?->unit_id); - - $recalculateTotal($get, $set); - }) - ->dehydrated(false) - ->required(), + ->displayFormat('l, d F Y'), Select::make('customer_id') ->label('Pelanggan') @@ -81,43 +47,48 @@ public static function configure(Schema $schema): Schema ->preload() ->native(false) ->required(), + ]), - DatePicker::make('stored_date') - ->label('Tanggal Penyimpanan') - ->default(now()) - ->required() - ->native(false) - ->displayFormat('l, d F Y'), - + Grid::make(3) + ->schema([ TextInput::make('quantity') ->label('Jumlah Barang') ->placeholder('0') ->autocomplete(false) ->required() ->live() - ->afterStateUpdated(function ($state, callable $get, callable $set) use ($recalculateTotal): void { + ->afterStateUpdated(function ($state, callable $get, callable $set) use ($recalculateTotal, $recalculateRemaining): void { $recalculateTotal($get, $set); + $recalculateRemaining($get, $set); }) ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 0) ->dehydrateStateUsing(fn ($state) => (int) str()->replace('.', '', (string) ($state ?? 0))), - ]), - Grid::make(2) - ->schema([ TextInput::make('unit_price') ->label('Harga per Satuan') ->placeholder('0') - ->readOnly() + ->autocomplete(false) ->prefix('Rp') ->required() - ->formatStateUsing( - fn ($state) => number_format((int) ($state ?? 0), 0, ',', '.') - ) + ->live() + ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 0) ->dehydrateStateUsing(fn ($state) => (int) str()->replace('.', '', (string) ($state ?? 0))) - ->afterStateUpdated(function ($state, callable $get, callable $set) use ($recalculateTotal): void { + ->afterStateUpdated(function ($state, callable $get, callable $set) use ($recalculateTotal, $recalculateRemaining): void { $recalculateTotal($get, $set); + $recalculateRemaining($get, $set); }), + Select::make('unit_id') + ->label('Satuan') + ->relationship('unit', 'alias') + ->searchable() + ->preload() + ->native(false) + ->required(), + ]), + + Grid::make(3) + ->schema([ TextInput::make('total_amount') ->label('Total') ->placeholder('0') @@ -129,10 +100,7 @@ public static function configure(Schema $schema): Schema fn ($state) => number_format((int) ($state ?? 0), 0, ',', '.') ) ->dehydrateStateUsing(fn ($state) => (int) str()->replace('.', '', (string) ($state ?? 0))), - ]), - Grid::make(3) - ->schema([ TextInput::make('paid_amount') ->label('Jumlah yang Sudah Dibayar (DP)') ->placeholder('0') @@ -142,10 +110,12 @@ public static function configure(Schema $schema): Schema ->live() ->prefix('Rp') ->readOnly(fn (callable $get) => $get('is_paid')) - ->afterStateUpdated(function ($state, callable $get, callable $set): void { + ->afterStateUpdated(function ($state, callable $get, callable $set) use ($recalculateRemaining): void { $paidAmount = (int) str()->replace('.', '', (string) ($state ?? 0)); $totalAmount = (int) str()->replace('.', '', (string) ($get('total_amount') ?? 0)); + $recalculateRemaining($get, $set); + if (! $get('is_paid')) { $set('is_paid', $paidAmount >= $totalAmount && $totalAmount > 0); } @@ -167,6 +137,7 @@ public static function configure(Schema $schema): Schema ->readOnly() ->prefix('Rp') ->default(0) + ->live() ->formatStateUsing(function ($state, callable $get) { $paidAmount = (int) str()->replace('.', '', (string) ($get('paid_amount') ?? 0)); $totalAmount = (int) str()->replace('.', '', (string) ($get('total_amount') ?? 0)); @@ -174,14 +145,13 @@ public static function configure(Schema $schema): Schema return number_format($remaining, 0, ',', '.'); }) - ->dehydrated(false) - ->live(), + ->dehydrated(false), Toggle::make('is_paid') ->label('Lunas') ->default(false) ->live() - ->afterStateUpdated(function ($state, callable $get, callable $set): void { + ->afterStateUpdated(function ($state, callable $get, callable $set) use ($recalculateRemaining): void { $totalAmount = (int) str()->replace('.', '', (string) ($get('total_amount') ?? 0)); if ($state) { @@ -194,6 +164,8 @@ public static function configure(Schema $schema): Schema $set('paid_amount', 0); $set('payment_date', null); } + + $recalculateRemaining($get, $set); }), DatePicker::make('payment_date') diff --git a/app/Filament/Resources/Manage/Orders/OrderResource.php b/app/Filament/Resources/Manage/Orders/OrderResource.php index e6cd09c..e866c99 100644 --- a/app/Filament/Resources/Manage/Orders/OrderResource.php +++ b/app/Filament/Resources/Manage/Orders/OrderResource.php @@ -10,12 +10,10 @@ use App\Filament\Actions\DefaultBulkActions; use App\Filament\Columns\TimestampColumns; use App\Filament\Resources\Manage\Orders\Pages\ManageOrders; -use App\Models\EggPrice; use App\Models\Order; use BackedEnum; use Filament\Actions\BulkActionGroup; use Filament\Forms\Components\DatePicker; -use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Select; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; @@ -59,132 +57,90 @@ public static function form(Schema $schema): Schema $set('total_amount', number_format($totalAmount, 0, ',', '.')); }; - return $schema->components([ - Hidden::make('unit_id') - ->required(), + return $schema + ->components([ + DatePicker::make('order_date') + ->label('Tanggal Order') + ->default(now()) + ->required() + ->native(false) + ->displayFormat('l, d F Y'), - Grid::make(2) - ->schema([ - Select::make('egg_price_id') - ->label('Harga Telur') - ->options( - EggPrice::query() - ->with('unit') - ->orderBy('name') - ->get() - ->mapWithKeys(function ($item) { - return [$item->id => $item->name.' ('.($item->unit?->alias ?? '-').')']; - }) - ) - ->searchable() - ->preload() - ->native(false) - ->live() - ->afterStateHydrated(function ($state, callable $set, callable $get, $record): void { - if ($record && ! $state) { - $eggPrice = EggPrice::where('unit_id', $record->unit_id) - ->where('price', $record->unit_price) - ->first(); + Select::make('customer_id') + ->label('Pelanggan') + ->relationship('customer', 'name') + ->searchable() + ->preload() + ->native(false), - if ($eggPrice) { - $set('egg_price_id', $eggPrice->id); - } - } - }) - ->afterStateUpdated(function ($state, callable $set, callable $get) use ($recalculateTotal): void { - if (! $state) { - $set('unit_price', 0); - $set('unit_id', null); + Grid::make(3) + ->schema([ + TextInput::make('egg_quantity') + ->label('Jumlah Telur') + ->placeholder('0') + ->autocomplete(false) + ->helperText('Jumlah per satuan.') + ->required() + ->live() + ->afterStateUpdated(function ($state, callable $get, callable $set) use ($recalculateTotal): void { $recalculateTotal($get, $set); + }) + ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 0) + ->dehydrateStateUsing(fn ($state) => (int) str()->replace('.', '', (string) ($state ?? 0))), - return; - } + TextInput::make('unit_price') + ->label('Harga per Satuan') + ->placeholder('0') + ->autocomplete(false) + ->prefix('Rp') + ->required() + ->live() + ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 0) + ->dehydrateStateUsing(fn ($state) => (int) str()->replace('.', '', (string) ($state ?? 0))) + ->afterStateUpdated(function ($state, callable $get, callable $set) use ($recalculateTotal): void { + $recalculateTotal($get, $set); + }), - $price = EggPrice::with('unit')->find($state); + Select::make('unit_id') + ->label('Satuan') + ->relationship('unit', 'alias') + ->searchable() + ->preload() + ->native(false) + ->required(), + ]) + ->columnSpanFull(), - $set('unit_price', number_format($price?->price ?? 0, 0, ',', '.')); - $set('unit_id', $price?->unit_id); + TextInput::make('discount') + ->label('Diskon') + ->placeholder('0') + ->default(0) + ->prefix('Rp') + ->live() + ->afterStateUpdated(function ($state, callable $get, callable $set) use ($recalculateTotal): void { + $recalculateTotal($get, $set); + }) + ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 0) + ->dehydrateStateUsing(fn ($state) => (int) str()->replace('.', '', (string) ($state ?? 0))), - $recalculateTotal($get, $set); - }) - ->dehydrated(false) - ->required(), + TextInput::make('total_amount') + ->label('Total') + ->placeholder('0') + ->readOnly() + ->prefix('Rp') + ->required() + ->formatStateUsing( + fn ($state) => number_format((int) ($state ?? 0), 0, ',', '.') + ) + ->dehydrateStateUsing(fn ($state) => (int) str()->replace('.', '', (string) ($state ?? 0))), - Select::make('customer_id') - ->label('Pelanggan') - ->relationship('customer', 'name') - ->searchable() - ->preload() - ->native(false), - - DatePicker::make('order_date') - ->label('Tanggal Order') - ->default(now()) - ->required() - ->native(false) - ->displayFormat('l, d F Y'), - - TextInput::make('egg_quantity') - ->label('Jumlah Telur') - ->placeholder('0') - ->autocomplete(false) - ->helperText('Jumlah per satuan.') - ->required() - ->live() - ->afterStateUpdated(function ($state, callable $get, callable $set) use ($recalculateTotal): void { - $recalculateTotal($get, $set); - }) - ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 0) - ->dehydrateStateUsing(fn ($state) => (int) str()->replace('.', '', (string) ($state ?? 0))), - ]), - - Grid::make(3) - ->schema([ - TextInput::make('unit_price') - ->label('Harga per Satuan') - ->placeholder('0') - ->readOnly() - ->prefix('Rp') - ->required() - ->formatStateUsing( - fn ($state) => number_format((int) ($state ?? 0), 0, ',', '.') - ) - ->dehydrateStateUsing(fn ($state) => (int) str()->replace('.', '', (string) ($state ?? 0))) - ->afterStateUpdated(function ($state, callable $get, callable $set) use ($recalculateTotal): void { - $recalculateTotal($get, $set); - }), - - TextInput::make('discount') - ->label('Diskon') - ->placeholder('0') - ->default(0) - ->prefix('Rp') - ->live() - ->afterStateUpdated(function ($state, callable $get, callable $set) use ($recalculateTotal): void { - $recalculateTotal($get, $set); - }) - ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 0) - ->dehydrateStateUsing(fn ($state) => (int) str()->replace('.', '', (string) ($state ?? 0))), - - TextInput::make('total_amount') - ->label('Total') - ->placeholder('0') - ->readOnly() - ->prefix('Rp') - ->required() - ->formatStateUsing( - fn ($state) => number_format((int) ($state ?? 0), 0, ',', '.') - ) - ->dehydrateStateUsing(fn ($state) => (int) str()->replace('.', '', (string) ($state ?? 0))), - ]), - - Textarea::make('notes') - ->label('Catatan') - ->placeholder('...') - ->autocomplete(false) - ->columnSpanFull(), - ]) - ->columns(1); + Textarea::make('notes') + ->label('Catatan') + ->placeholder('...') + ->autocomplete(false) + ->columnSpanFull(), + ]) + ->columns(2); } public static function table(Table $table): Table @@ -223,6 +179,12 @@ public static function table(Table $table): Table ->money('IDR', decimalPlaces: 0) ->sortable(), + TextColumn::make('notes') + ->label('Catatan') + ->sortable() + ->searchable() + ->toggleable(isToggledHiddenByDefault: true), + ...TimestampColumns::make(), ]) ->filters([ diff --git a/app/Filament/Resources/Master/EggPrices/EggPriceResource.php b/app/Filament/Resources/Master/EggPrices/EggPriceResource.php deleted file mode 100644 index 2fd2105..0000000 --- a/app/Filament/Resources/Master/EggPrices/EggPriceResource.php +++ /dev/null @@ -1,134 +0,0 @@ -components([ - TextInput::make('name') - ->label('Tipe Harga') - ->placeholder('Ecer, Distributor, Grosir') - ->required() - ->maxLength(50) - ->autofocus() - ->autocomplete(false), - - Select::make('unit_id') - ->label('Satuan') - ->relationship('unit', 'name') - ->required() - ->native(false) - ->searchable() - ->preload(), - - TextInput::make('price') - ->label('Harga') - ->placeholder('0') - ->autocomplete(false) - ->required() - ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 0) - ->prefix('Rp') - ->dehydrateStateUsing(fn ($state) => (int) str()->replace(',', '', (string) ($state ?? 0))), - ]) - ->columns(1); - } - - public static function table(Table $table): Table - { - return $table - ->columns([ - TextColumn::make('name') - ->label('Tipe Harga') - ->searchable() - ->sortable(), - - TextColumn::make('price') - ->label('Harga') - ->money('IDR', decimalPlaces: 0) - ->suffix(fn (EggPrice $record) => ' / '.$record->unit?->alias) - ->sortable(), - - ...TimestampColumns::make(), - ]) - ->filters([ - TrashedFilter::make() - ->native(false) - ->visible(fn (): bool => auth()->user()->hasRole(RoleEnum::DEVELOPER)), - ]) - ->recordActions([ - EditAction::make() - ->modalWidth(Width::Large), - - DeleteAction::make(), - - ForceDeleteAction::make(), - - RestoreAction::make(), - ]) - ->toolbarActions([ - BulkActionGroup::make([ - ...DefaultBulkActions::make('Harga Telur'), - ]), - ]) - ->emptyStateIcon(Heroicon::CurrencyDollar) - ->emptyStateDescription('Setelah Anda membuat data pertama, maka akan muncul disini.') - ->defaultSort('created_at', 'desc') - ->deferFilters(false); - } - - public static function getPages(): array - { - return [ - 'index' => ManageEggPrices::route('/'), - ]; - } - - public static function getRecordRouteBindingEloquentQuery(): Builder - { - return parent::getRecordRouteBindingEloquentQuery() - ->withoutGlobalScopes([ - SoftDeletingScope::class, - ]); - } -} diff --git a/app/Filament/Resources/Master/EggPrices/Pages/ManageEggPrices.php b/app/Filament/Resources/Master/EggPrices/Pages/ManageEggPrices.php deleted file mode 100644 index 2ce5557..0000000 --- a/app/Filament/Resources/Master/EggPrices/Pages/ManageEggPrices.php +++ /dev/null @@ -1,31 +0,0 @@ -label('Tambah') - ->modalHeading('Tambah Harga Telur') - ->modalSubmitActionLabel('Simpan') - ->modalCancelActionLabel('Batal') - ->extraModalFooterActions(fn (CreateAction $action): array => [ - $action->makeModalSubmitAction('createAnother', arguments: ['another' => true]) - ->label('Simpan dan Tambah Lagi'), - ]) - ->modalWidth(Width::Large), - ]; - } -} diff --git a/app/Models/EggPrice.php b/app/Models/EggPrice.php deleted file mode 100644 index 1b7e6d1..0000000 --- a/app/Models/EggPrice.php +++ /dev/null @@ -1,27 +0,0 @@ - 'integer', - ]; - } - - public function unit(): BelongsTo - { - return $this->belongsTo(Unit::class); - } -} diff --git a/app/Policies/EggPricePolicy.php b/app/Policies/EggPricePolicy.php deleted file mode 100644 index 5e1f2c2..0000000 --- a/app/Policies/EggPricePolicy.php +++ /dev/null @@ -1,69 +0,0 @@ -can('ViewAny:EggPrice'); - } - - public function view(AuthUser $authUser, EggPrice $eggPrice): bool - { - return $authUser->can('View:EggPrice'); - } - - public function create(AuthUser $authUser): bool - { - return $authUser->can('Create:EggPrice'); - } - - public function update(AuthUser $authUser, EggPrice $eggPrice): bool - { - return $authUser->can('Update:EggPrice'); - } - - public function delete(AuthUser $authUser, EggPrice $eggPrice): bool - { - return $authUser->can('Delete:EggPrice'); - } - - public function restore(AuthUser $authUser, EggPrice $eggPrice): bool - { - return $authUser->can('Restore:EggPrice'); - } - - public function forceDelete(AuthUser $authUser, EggPrice $eggPrice): bool - { - return $authUser->can('ForceDelete:EggPrice'); - } - - public function forceDeleteAny(AuthUser $authUser): bool - { - return $authUser->can('ForceDeleteAny:EggPrice'); - } - - public function restoreAny(AuthUser $authUser): bool - { - return $authUser->can('RestoreAny:EggPrice'); - } - - public function replicate(AuthUser $authUser, EggPrice $eggPrice): bool - { - return $authUser->can('Replicate:EggPrice'); - } - - public function reorder(AuthUser $authUser): bool - { - return $authUser->can('Reorder:EggPrice'); - } -} diff --git a/database/factories/EggPriceFactory.php b/database/factories/EggPriceFactory.php deleted file mode 100644 index 34184df..0000000 --- a/database/factories/EggPriceFactory.php +++ /dev/null @@ -1,26 +0,0 @@ - - */ -class EggPriceFactory extends Factory -{ - protected $model = EggPrice::class; - - public function definition(): array - { - $unit = Unit::inRandomOrder()->first() ?? Unit::factory()->create(); - - return [ - 'name' => $this->faker->randomElement(['Ecer', 'Grosir', 'Distributor']).' '.$this->faker->randomElement(['Pagi', 'Siang', 'Malam']), - 'unit_id' => $unit->id, - 'price' => $this->faker->numberBetween(1500, 3000), - ]; - } -} diff --git a/database/factories/OrderFactory.php b/database/factories/OrderFactory.php index 4811756..b7ebb70 100644 --- a/database/factories/OrderFactory.php +++ b/database/factories/OrderFactory.php @@ -3,8 +3,8 @@ namespace Database\Factories; use App\Models\Customer; -use App\Models\EggPrice; use App\Models\Order; +use App\Models\Unit; use Illuminate\Database\Eloquent\Factories\Factory; /** @@ -23,19 +23,19 @@ public function definition(): array { $date = $this->faker->dateTimeBetween('-3 months', 'now'); - $eggPrice = EggPrice::inRandomOrder()->first() ?? EggPrice::factory()->create(); + $eggPrice = $this->faker->numberBetween(28000, 35000); $customer = Customer::inRandomOrder()->first() ?? Customer::factory()->create(); $eggQuantity = $this->faker->numberBetween(10, 500); - $unitPrice = $eggPrice->price; + $unitPrice = $eggPrice / 10; $discount = $this->faker->optional(0.3)->numberBetween(5000, 50000) ?? 0; $subtotal = $eggQuantity * $unitPrice; $totalAmount = max(0, $subtotal - $discount); return [ 'customer_id' => $customer->id, - 'unit_id' => $eggPrice->unit_id, + 'unit_id' => Unit::inRandomOrder()->first()->id ?? Unit::factory()->create()->id, 'egg_quantity' => $eggQuantity, 'unit_price' => $unitPrice, 'order_date' => $date, diff --git a/database/migrations/2026_02_18_000006_create_egg_prices_table.php b/database/migrations/2026_02_18_000006_create_egg_prices_table.php deleted file mode 100644 index 8a43a91..0000000 --- a/database/migrations/2026_02_18_000006_create_egg_prices_table.php +++ /dev/null @@ -1,26 +0,0 @@ -id(); - $table->string('name', 50); - $table->foreignId('unit_id')->constrained()->cascadeOnDelete(); - $table->unsignedInteger('price'); - $table->timestamp('created_at')->useCurrent(); - $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); - $table->softDeletes(); - }); - } - - public function down(): void - { - Schema::dropIfExists('egg_prices'); - } -}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index f71350b..9fb91fb 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -24,7 +24,6 @@ public function run(): void FeedPurchaseSeeder::class, EggCollectionSeeder::class, CustomerSeeder::class, - EggPriceSeeder::class, OrderSeeder::class, DelayedGoodSeeder::class, ExpenseSeeder::class, diff --git a/database/seeders/EggPriceSeeder.php b/database/seeders/EggPriceSeeder.php deleted file mode 100644 index f17b606..0000000 --- a/database/seeders/EggPriceSeeder.php +++ /dev/null @@ -1,64 +0,0 @@ -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'], - ] - ); - } - } -}