parfum/app/Livewire/Studio/Catalog/Bottle/Edit.php

50 lines
1.2 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\Authorization\WithAuthorization;
use App\Traits\Components\WithOutletSelector;
use App\Traits\Components\WithToast;
use App\Traits\Utilities\WithUpdatedData;
use Illuminate\Contracts\View\View;
use Livewire\Attributes\Title;
use Livewire\Component;
#[Title('Ubah Botol')]
class Edit extends Component
{
use WithAuthorization, WithOutletSelector, WithToast, WithUpdatedData;
public BottleForm $form;
public array $outlets = [];
public function mount(Bottle $bottle): void
{
$this->form->setBottle($bottle);
$this->outlets = Outlet::pluck('name', 'id')->toArray();
}
public function save(): void
{
$this->canOrAbort('update bottle');
$this->form->update();
$this->redirectRoute('studio.catalog.bottle.index', [
'notification' => 'Botol berhasil diperbarui.',
], navigate: true);
}
public function render(): View
{
return view('livewire.studio.catalog.bottle.form', [
'pageTitle' => 'Ubah Botol',
]);
}
}