<?php

use Livewire\Component;
use App\Models\Inquiry;

return new class extends Component
{
    public $filter = 'all';

    public function render()
    {
        return $this->view()->layout('layouts::auth');
    }

    public function archive($id)
    {
        Inquiry::find($id)->update(['status' => 'archived']);
        session()->flash('message', 'Inquiry archived.');
    }

    public function with()
    {
        $query = Inquiry::latest();

        if ($this->filter === 'unread') {
            $query->where('status', 'new');
        } elseif ($this->filter === 'archive') {
            $query->where('status', 'archived');
        }

        return [
            'inquiries' => $query->get(),
        ];
    }

    protected function view($data = [])
    {
        return app('view')->file('D:\02-my freelance\00-DR_Padhi\DR_PADHI\storage\framework/views/livewire/views/d0f124da.blade.php', $data);
    }
};
