outlets = Outlet::pluck('name', 'id')->toArray(); $this->perfumes = Perfume::pluck('name', 'id')->toArray(); $this->products = Product::pluck('name', 'id')->toArray(); $this->bottles = Bottle::pluck('name', 'id')->toArray(); $this->form->cartItems = PurchaseItem::whereNull('purchase_id')->get(); $this->form->total = currency($this->form->cartItems->sum('total_price'), ''); } public function save() { if ($this->form->cartItems->isEmpty()) { $this->toast('Keranjang tidak boleh kosong.', 'Gagal', 'danger'); return; } $this->canOrAbort('create purchase'); $this->form->store(); $this->dispatch('refreshDatatable'); $this->toast('Belanja berhasil ditambahkan.'); $this->redirectRoute('studio.manage.purchase.index', navigate: true); } public function render() { return view('livewire.studio.manage.purchase.form', [ 'pageTitle' => 'Tambah Belanja', ]); } }