<?php

namespace App\Livewire\Studio\Catalog\Perfume;

use App\Models\Perfume;
use App\Traits\Authorization\WithAuthorization;
use App\Traits\Components\WithConfirmation;
use App\Traits\Components\WithToast;
use App\Traits\Notification\WithSubscribeNotification;
use App\Traits\Utilities\WithRequestNotification;
use Flux\Flux;
use Livewire\Attributes\Title;
use Livewire\Component;

#[Title('Parfum')]
class Index extends Component
{
    use WithAuthorization, WithConfirmation, WithRequestNotification, WithSubscribeNotification, WithToast;

    public function delete(Perfume $perfume)
    {
        $this->canOrAbort('delete perfume');

        $perfume->delete();

        $this->dispatch('refreshDatatable');

        $this->toast('Parfum berhasil dihapus.');

        Flux::modals()->close();
    }

    public function render()
    {
        return view('livewire.studio.catalog.perfume.index', [
            'pageTitle' => 'Parfum',
        ]);
    }
}
