refactor(modal): Simplify modal ID handling by replacing if statements with short-circuit evaluation across multiple components.

This commit is contained in:
Yoga Pangestu 2025-12-14 10:33:48 +07:00
parent 1f29e4193d
commit ffba4df0dc
10 changed files with 10 additions and 30 deletions

View File

@ -89,9 +89,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null
$this->method = $method;
$this->modalTitle = $modalTitle;
if ($id) {
$this->form->setBrand(BrandModel::byHashOrFail($id));
}
$id && $this->form->setBrand(BrandModel::byHashOrFail($id));
}
public function render(): View

View File

@ -89,9 +89,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null
$this->method = $method;
$this->modalTitle = $modalTitle;
if ($id) {
$this->form->setCategory(CategoryModel::byHashOrFail($id));
}
$id && $this->form->setCategory(CategoryModel::byHashOrFail($id));
}
public function render(): View

View File

@ -89,9 +89,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null
$this->method = $method;
$this->modalTitle = $modalTitle;
if ($id) {
$this->form->setChooseUs(ChooseUsModel::byHashOrFail($id));
}
$id && $this->form->setChooseUs(ChooseUsModel::byHashOrFail($id));
}
public function render(): View

View File

@ -89,9 +89,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null
$this->method = $method;
$this->modalTitle = $modalTitle;
if ($id) {
$this->form->setPerfumeFeature(PerfumeFeatureModel::byHashOrFail($id));
}
$id && $this->form->setPerfumeFeature(PerfumeFeatureModel::byHashOrFail($id));
}
public function render(): View

View File

@ -88,9 +88,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null
$this->method = $method;
$this->modalTitle = $modalTitle;
if ($id) {
$this->form->setExpense(ExpenseModel::byHashOrFail($id));
}
$id && $this->form->setExpense(ExpenseModel::byHashOrFail($id));
}
public function render(): View

View File

@ -83,9 +83,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null
$this->method = $method;
$this->modalTitle = $modalTitle;
if ($id) {
$this->form->setBroadcast(BroadcastModel::byHashOrFail($id));
}
$id && $this->form->setBroadcast(BroadcastModel::byHashOrFail($id));
}
public function render(): View

View File

@ -89,9 +89,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null
$this->method = $method;
$this->modalTitle = $modalTitle;
if ($id) {
$this->form->setFaq(FaqModel::byHashOrFail($id));
}
$id && $this->form->setFaq(FaqModel::byHashOrFail($id));
}
public function render(): View

View File

@ -56,9 +56,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null
$this->method = $method;
$this->modalTitle = $modalTitle;
if ($id) {
$this->form->setCustomer(CustomerModel::byHashOrFail($id));
}
$id && $this->form->setCustomer(CustomerModel::byHashOrFail($id));
}
public function create(): void

View File

@ -178,9 +178,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null
$this->method = $method;
$this->modalTitle = $modalTitle;
if ($id) {
$this->form->setTier(TierModel::byHashOrFail($id));
}
$id && $this->form->setTier(TierModel::byHashOrFail($id));
}
public function render(): View

View File

@ -164,9 +164,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null
$this->method = $method;
$this->modalTitle = $modalTitle;
if ($id) {
$this->form->setFormula(FormulaModel::byHashOrFail($id));
}
$id && $this->form->setFormula(FormulaModel::byHashOrFail($id));
}
public function render(): View