diff --git a/app/Livewire/Studio/Master/Formula.php b/app/Livewire/Studio/Master/Formula.php index 204ed23..7c9e9b1 100644 --- a/app/Livewire/Studio/Master/Formula.php +++ b/app/Livewire/Studio/Master/Formula.php @@ -69,14 +69,14 @@ public function openModal(string $method, string $modalTitle, ?string $id = null public function create(): void { + $this->canOrAbort('create formula'); + if (FormulaModel::where('quality', $this->form->quality)->where('size', $this->form->size)->exists()) { $this->toast('Rumus dengan kualitas dan ukuran tersebut sudah ada.', 'Info', 'warning'); return; } - $this->canOrAbort('create formula'); - $formula = $this->form->store(); // push new formula to collection @@ -115,6 +115,8 @@ public function create(): void public function update(): void { + $this->canOrAbort('update formula'); + $exists = FormulaModel::where('quality', $this->form->quality) ->where('size', $this->form->size) ->where('id', '!=', $this->form->formula->id) @@ -126,8 +128,6 @@ public function update(): void return; } - $this->canOrAbort('update formula'); - $formula = $this->form->update(); // update collection formulas