parfum/app/Livewire/Studio/Catalog/Bottle/Edit.php
Yoga Pangestu e905f98b4f feat(role & permission): membuat trait untuk otorisasi
-menambahkan otorisasi semua komponen. tabel, view dan lainnya
2025-10-02 21:42:08 +07:00

50 lines
1.1 KiB
PHP

<?php
namespace App\Livewire\Studio\Catalog\Bottle;
use App\Livewire\Forms\Studio\Catalog\BottleForm;
use App\Models\Bottle;
use App\Models\Outlet;
use App\Traits\WithOutletSelector;
use App\Traits\WithToast;
use App\Traits\WithUpdatedData;
use Livewire\Attributes\Title;
use Livewire\Component;
#[Title('Ubah Botol')]
class Edit extends Component
{
use WithOutletSelector, WithToast, WithUpdatedData;
public BottleForm $form;
public array $outlets = [];
public function mount(Bottle $bottle)
{
$this->form->setBottle($bottle);
$this->outlets = Outlet::pluck('name', 'id')->toArray();
}
public function save()
{
$this->canOrAbort('update bottle');
$this->form->update();
$this->dispatch('refreshDatatable');
$this->toast('Botol berhasil diperbarui.');
$this->redirectRoute('studio.catalog.bottle.index', navigate: true);
}
public function render()
{
return view('livewire.studio.catalog.bottle.form', [
'pageTitle' => 'Ubah Botol',
]);
}
}