parfum/app/Livewire/Studio/Catalog/Perfume/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

56 lines
1.3 KiB
PHP

<?php
namespace App\Livewire\Studio\Catalog\Perfume;
use App\Livewire\Forms\Studio\Catalog\PerfumeForm;
use App\Models\Brand;
use App\Models\Category;
use App\Models\Outlet;
use App\Traits\WithCategorySelector;
use App\Traits\WithOutletSelector;
use App\Traits\WithToast;
use App\Traits\WithUpdatedData;
use Livewire\Attributes\Title;
use Livewire\Component;
#[Title('Tambah Parfum')]
class Create extends Component
{
use WithCategorySelector, WithOutletSelector, WithToast, WithUpdatedData;
public PerfumeForm $form;
public array $outlets = [];
public array $brands = [];
public array $categories = [];
public function mount()
{
$this->outlets = Outlet::pluck('name', 'id')->toArray();
$this->brands = Brand::pluck('name', 'id')->toArray();
$this->categories = Category::pluck('name', 'id')->toArray();
}
public function save()
{
$this->form->store();
$this->dispatch('refreshDatatable');
$this->toast('Parfum berhasil ditambahkan.');
$this->redirectRoute('studio.catalog.perfume.index', navigate: true);
}
public function render()
{
return view('livewire.studio.catalog.perfume.form', [
'pageTitle' => 'Tambah Parfum',
]);
}
}