50 lines
1.1 KiB
PHP
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',
|
|
]);
|
|
}
|
|
}
|