warehouses = WarehouseModel::orderBy('name')->pluck('name', 'id')->toArray(); $this->perfumes = Perfume::orderBy('name')->pluck('name', 'id')->toArray(); $this->bottles = Bottle::orderBy('name')->pluck('name', 'id')->toArray(); $this->products = Product::orderBy('name')->pluck('name', 'id')->toArray(); $this->purchaseItems = $this->loadPurchaseItems(); $this->form->total = $this->getTotal(); } public function save(): void { $this->canOrAbort('create purchase'); if ($this->purchaseItems->isEmpty()) { $this->toast('Keranjang tidak boleh kosong.', 'Gagal', 'danger'); return; } $this->form->store(); $this->redirectRoute('studio.stock.purchase.index', [ 'notification' => 'Belanja berhasil ditambahkan.', ], navigate: true); } public function render(): View { return view('livewire.studio.stock.purchase.form', [ 'pageTitle' => 'Tambah Belanja', ]); } }