parfum/app/Livewire/Studio/Loyalty/Voucher/Create.php
Yoga Pangestu 700aa8f260 feat(trait): membuat trait untuk toast agar reusable
-mengubah cara menulis toast diubah menjadi memanggil toast yang ada
2025-10-02 20:13:03 +07:00

45 lines
973 B
PHP

<?php
namespace App\Livewire\Studio\Loyalty\Voucher;
use App\Livewire\Forms\Studio\Loyalty\VoucherForm;
use App\Models\Outlet;
use App\Traits\WithOutletSelector;
use App\Traits\WithToast;
use App\Traits\WithUpdatedData;
use Livewire\Attributes\Title;
use Livewire\Component;
#[Title('Tambah Voucher')]
class Create extends Component
{
use WithOutletSelector, WithToast, 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');
$this->toast('Voucher berhasil ditambahkan.');
$this->redirectRoute('studio.loyalty.voucher.index', navigate: true);
}
public function render()
{
return view('livewire.studio.loyalty.voucher.form', [
'pageTitle' => 'Tambah Voucher',
]);
}
}