outlets = auth()->user()->outlets->pluck('name', 'id')->toArray(); // Set default outlet if only one available if (count($this->outlets) === 1) { $this->form->outlet_id = key($this->outlets); } $this->perfumes = Perfume::orderBy('name')->pluck('name', 'id')->toArray(); $this->bottles = Bottle::orderBy('size')->pluck('name', 'id')->toArray(); $this->products = Product::orderBy('name')->pluck('name', 'id')->toArray(); $this->items = $this->loadOrderItems(); $this->subtotal = $this->getSubTotal(); $this->total = $this->getTotal(); } public function save() { $this->canOrAbort('create order'); if ($this->items->isEmpty()) { $this->toast('Keranjang tidak boleh kosong.', 'Gagal', 'danger'); return; } $result = $this->form->store(); if (! $result['status']) { $this->toast($result['message'], 'Gagal', 'danger'); return; } $this->dispatch('refreshDatatable'); $this->toast('Order berhasil ditambahkan.'); $this->redirectRoute('studio.manage.order.index', navigate: true); } public function render() { return view('livewire.studio.manage.order.form', [ 'pageTitle' => 'Tambah Order', ]); } }