<?php

namespace App\Livewire\Studio\Manage\Article;

use App\Models\Article;
use App\Traits\WithConfirmation;
use App\Traits\WithToast;
use Flux\Flux;
use Livewire\Attributes\Title;
use Livewire\Component;

#[Title('Artikel')]
class Index extends Component
{
    use WithConfirmation, WithToast;

    public function delete(Article $article)
    {
        $article->delete();

        $this->dispatch('refreshDatatable');

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

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

    public function render()
    {
        return view('livewire.studio.manage.article.index', [
            'pageTitle' => 'Artikel',
        ]);
    }
}
