parfum/app/Livewire/Studio/Loyalty/Voucher/Create.php

50 lines
1.0 KiB
PHP

<?php
namespace App\Livewire\Studio\Loyalty\Voucher;
use App\Livewire\Forms\VoucherForm;
use App\Models\Outlet;
use App\Traits\WithOutletSelector;
use App\Traits\WithUpdatedData;
use Flux\Flux;
use Livewire\Attributes\Title;
use Livewire\Component;
#[Title('Tambah Voucher')]
class Create extends Component
{
use WithOutletSelector, WithUpdatedData;
public VoucherForm $form;
public array $outlets;
public function mount()
{
$this->outlets = Outlet::pluck('name', 'id')->toArray();
}
public function save()
{
$this->form->store();
$this->dispatch('refreshDatatable');
Flux::toast(
heading: 'Berhasil',
text: 'Voucher berhasil ditambahkan.',
variant: 'success',
duration: 3000
);
$this->redirectRoute('studio.loyalty.voucher.index', navigate: true);
}
public function render()
{
return view('livewire.studio.loyalty.voucher.form', [
'pageTitle' => 'Tambah Voucher',
]);
}
}