refactor(brand): menambahkan return type
This commit is contained in:
parent
ba27aa4048
commit
0c7ab27a78
@ -87,7 +87,6 @@ public function columns(): array
|
||||
if (auth()->user()->can('delete brand')) {
|
||||
$actions .= view('components.actions.table.delete', [
|
||||
'id' => $row->hash,
|
||||
'deleteRoute' => route('studio.catalog.brand.delete', $row->hash),
|
||||
])->render();
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'max:20', Rule::unique('brands', 'name')->whereNull('deleted_at')->ignore($this->brand)],
|
||||
'image' => ['nullable', 'array'],
|
||||
'image' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ public function validationAttributes(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function setBrand(Brand $brand)
|
||||
public function setBrand(Brand $brand): void
|
||||
{
|
||||
$this->brand = $brand;
|
||||
|
||||
@ -43,7 +43,7 @@ public function setBrand(Brand $brand)
|
||||
$this->image = $this->mapMediaCollection($brand->getMedia('image'));
|
||||
}
|
||||
|
||||
public function store()
|
||||
public function store(): void
|
||||
{
|
||||
$this->validate();
|
||||
|
||||
@ -57,7 +57,7 @@ public function store()
|
||||
});
|
||||
}
|
||||
|
||||
public function update()
|
||||
public function update(): void
|
||||
{
|
||||
$this->validate();
|
||||
|
||||
@ -71,7 +71,7 @@ public function update()
|
||||
});
|
||||
}
|
||||
|
||||
public function delete()
|
||||
public function delete(): void
|
||||
{
|
||||
$this->brand->delete();
|
||||
|
||||
@ -83,7 +83,7 @@ public function delete()
|
||||
});
|
||||
}
|
||||
|
||||
public function sortOrder(string $direction)
|
||||
public function sortOrder(string $direction): void
|
||||
{
|
||||
if (in_array($direction, ['up', 'down'])) {
|
||||
$swap = null;
|
||||
@ -112,7 +112,7 @@ public function sortOrder(string $direction)
|
||||
}
|
||||
}
|
||||
|
||||
protected function normalizeSortOrder()
|
||||
protected function normalizeSortOrder(): void
|
||||
{
|
||||
$categories = Brand::orderBy('sort_order')->get();
|
||||
foreach ($categories as $index => $brand) {
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
use App\Traits\WithToast;
|
||||
use App\Traits\WithUpdatedData;
|
||||
use Flux\Flux;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Component;
|
||||
@ -26,21 +27,7 @@ class Brand extends Component
|
||||
|
||||
public string $modalTitle = '';
|
||||
|
||||
#[On('modal:open')]
|
||||
public function openModal(string $method, string $modalTitle, ?string $id = null)
|
||||
{
|
||||
$this->resetValidation();
|
||||
$this->resetErrorBag();
|
||||
|
||||
$this->method = $method;
|
||||
$this->modalTitle = $modalTitle;
|
||||
|
||||
if ($id) {
|
||||
$this->form->setBrand(BrandModel::byHashOrFail($id));
|
||||
}
|
||||
}
|
||||
|
||||
public function create()
|
||||
public function create(): void
|
||||
{
|
||||
$this->canOrAbort('create brand');
|
||||
|
||||
@ -53,7 +40,7 @@ public function create()
|
||||
Flux::modals()->close();
|
||||
}
|
||||
|
||||
public function update()
|
||||
public function update(): void
|
||||
{
|
||||
$this->canOrAbort('update brand');
|
||||
|
||||
@ -66,8 +53,10 @@ public function update()
|
||||
Flux::modals()->close();
|
||||
}
|
||||
|
||||
public function delete(BrandModel $brand)
|
||||
public function delete(BrandModel $brand): void
|
||||
{
|
||||
$this->canOrAbort('delete brand');
|
||||
|
||||
$this->form->brand = $brand;
|
||||
|
||||
$this->form->delete();
|
||||
@ -80,7 +69,7 @@ public function delete(BrandModel $brand)
|
||||
}
|
||||
|
||||
#[On('fn:sortOrder')]
|
||||
public function sortOrder(BrandModel $brand, string $direction)
|
||||
public function sortOrder(BrandModel $brand, string $direction): void
|
||||
{
|
||||
$this->canOrAbort('update brand');
|
||||
|
||||
@ -91,7 +80,21 @@ public function sortOrder(BrandModel $brand, string $direction)
|
||||
$this->dispatch('refreshDatatable');
|
||||
}
|
||||
|
||||
public function render()
|
||||
#[On('modal:open')]
|
||||
public function openModal(string $method, string $modalTitle, ?string $id = null): void
|
||||
{
|
||||
$this->resetValidation();
|
||||
$this->resetErrorBag();
|
||||
|
||||
$this->method = $method;
|
||||
$this->modalTitle = $modalTitle;
|
||||
|
||||
if ($id) {
|
||||
$this->form->setBrand(BrandModel::byHashOrFail($id));
|
||||
}
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.studio.catalog.brands', [
|
||||
'pageTitle' => 'Merek',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user