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

47 lines
1.1 KiB
PHP

<?php
namespace App\Livewire\Studio\Catalog\Bottle;
use App\Livewire\Forms\Studio\Catalog\BottleForm;
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('Tambah Botol')]
class Create extends Component
{
use WithAuthorization, WithOutletSelector, WithToast, WithUpdatedData;
public BottleForm $form;
public array $outlets = [];
public function mount(): void
{
$this->outlets = Outlet::pluck('name', 'id')->toArray();
}
public function save(): void
{
$this->canOrAbort('create bottle');
$this->form->store();
$this->redirectRoute('studio.catalog.bottle.index', [
'notification' => 'Botol berhasil ditambahkan.',
], navigate: true);
}
public function render(): View
{
return view('livewire.studio.catalog.bottle.form', [
'pageTitle' => 'Tambah Botol',
]);
}
}