parfum/app/Livewire/Studio/Catalog/Perfume/Edit.php
Yoga Pangestu 81a9753620 feat(perfume. bottle): implementasi testing
- kasih return type
- ubah array to collection di audit
- mengubah waktu refresh tabel menjadi 30 detik
2025-12-11 11:15:59 +07:00

63 lines
1.5 KiB
PHP

<?php
namespace App\Livewire\Studio\Catalog\Perfume;
use App\Livewire\Forms\Studio\Catalog\PerfumeForm;
use App\Models\Brand;
use App\Models\Category;
use App\Models\Outlet;
use App\Models\Perfume;
use App\Traits\WithAuthorization;
use App\Traits\WithCategorySelector;
use App\Traits\WithOutletSelector;
use App\Traits\WithToast;
use App\Traits\WithUpdatedData;
use Illuminate\Contracts\View\View;
use Livewire\Attributes\Title;
use Livewire\Component;
#[Title('Ubah Parfum')]
class Edit extends Component
{
use WithAuthorization, WithCategorySelector, WithOutletSelector, WithToast, WithUpdatedData;
public PerfumeForm $form;
public array $outlets = [];
public array $brands = [];
public array $categories = [];
public function mount(Perfume $perfume): void
{
$this->form->setPerfume($perfume);
$this->outlets = Outlet::pluck('name', 'id')->toArray();
$this->brands = Brand::pluck('name', 'id')->toArray();
$this->categories = Category::pluck('name', 'id')->toArray();
}
public function save(): void
{
$this->canOrAbort('update perfume');
$this->form->update();
$this->dispatch('refreshDatatable');
$this->toast('Parfum berhasil diperbarui.');
$this->redirectRoute('studio.catalog.perfume.index');
}
public function render(): View
{
return view('livewire.studio.catalog.perfume.form', [
'pageTitle' => 'Ubah Parfum',
]);
}
}