parfum/app/Livewire/Studio/Master/Outlet/Create.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

53 lines
1.2 KiB
PHP

<?php
namespace App\Livewire\Studio\Master\Outlet;
use App\Enums\Day;
use App\Livewire\Forms\Studio\Master\OutletForm;
use App\Traits\Outlet\WithFacilityHandler;
use App\Traits\WithAuthorization;
use App\Traits\WithToast;
use App\Traits\WithUpdatedData;
use Livewire\Attributes\Title;
use Livewire\Component;
#[Title('Tambah Outlet')]
class Create extends Component
{
use WithAuthorization, WithFacilityHandler, WithToast, WithUpdatedData;
public OutletForm $form;
public array $days = [];
public function mount()
{
$this->form->opening_hours = collect(Day::cases())
->mapWithKeys(fn (Day $day) => [
$day->value => ['open_time' => null, 'close_time' => null],
])
->toArray();
$this->days = Day::cases();
}
public function save()
{
$this->canOrAbort('create outlet');
$this->form->store();
$this->dispatch('refreshDatatable');
$this->toast('Outlet berhasil ditambahkan.');
$this->redirectRoute('studio.master.outlet.index', navigate: true);
}
public function render()
{
return view('livewire.studio.master.outlet.form', [
'pageTitle' => 'Tambah Outlet',
]);
}
}