refactor(formula): memindahkan otorisasi ke atas
This commit is contained in:
parent
d02693ac64
commit
f75c5c6300
@ -69,14 +69,14 @@ public function openModal(string $method, string $modalTitle, ?string $id = null
|
|||||||
|
|
||||||
public function create(): void
|
public function create(): void
|
||||||
{
|
{
|
||||||
|
$this->canOrAbort('create formula');
|
||||||
|
|
||||||
if (FormulaModel::where('quality', $this->form->quality)->where('size', $this->form->size)->exists()) {
|
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');
|
$this->toast('Rumus dengan kualitas dan ukuran tersebut sudah ada.', 'Info', 'warning');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->canOrAbort('create formula');
|
|
||||||
|
|
||||||
$formula = $this->form->store();
|
$formula = $this->form->store();
|
||||||
|
|
||||||
// push new formula to collection
|
// push new formula to collection
|
||||||
@ -115,6 +115,8 @@ public function create(): void
|
|||||||
|
|
||||||
public function update(): void
|
public function update(): void
|
||||||
{
|
{
|
||||||
|
$this->canOrAbort('update formula');
|
||||||
|
|
||||||
$exists = FormulaModel::where('quality', $this->form->quality)
|
$exists = FormulaModel::where('quality', $this->form->quality)
|
||||||
->where('size', $this->form->size)
|
->where('size', $this->form->size)
|
||||||
->where('id', '!=', $this->form->formula->id)
|
->where('id', '!=', $this->form->formula->id)
|
||||||
@ -126,8 +128,6 @@ public function update(): void
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->canOrAbort('update formula');
|
|
||||||
|
|
||||||
$formula = $this->form->update();
|
$formula = $this->form->update();
|
||||||
|
|
||||||
// update collection formulas
|
// update collection formulas
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user