canOrAbort('create category'); $this->form->store(); $this->dispatch('refreshDatatable'); $this->toast('Kategori berhasil ditambahkan.'); Flux::modals()->close(); } public function update(): void { $this->canOrAbort('update category'); $this->form->update(); $this->dispatch('refreshDatatable'); $this->toast('Kategori berhasil diperbarui.'); Flux::modals()->close(); } public function delete(CategoryModel $category): void { $this->canOrAbort('delete category'); $this->form->category = $category; $this->form->delete(); $this->dispatch('refreshDatatable'); $this->toast('Kategori berhasil dihapus.'); Flux::modals()->close(); } #[On('fn:sortOrder')] public function sortOrder(CategoryModel $category, string $direction): void { $this->canOrAbort('update category'); $this->form->category = $category; $this->form->sortOrder($direction); $this->dispatch('refreshDatatable'); } #[On('modal:open')] public function openModal(string $method, string $modalTitle, ?string $id = null): void { $this->resetValidation(); $this->resetErrorBag(); $this->method = $method; $this->modalTitle = $modalTitle; $id && $this->form->setCategory(CategoryModel::byHashOrFail($id)); } public function updatedFormType(string $value): void { $this->showDescriptionAndImage = $value == CategoryType::PERFUME->value; } public function render(): View { return view('livewire.studio.master.categories', [ 'pageTitle' => 'Kategori', ]); } }