<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class ContactController extends Controller
{
    public function index()
    {
        $contacts = \App\Models\Contact::latest()->paginate(20);
        return view('admin.contacts.index', compact('contacts'));
    }

    public function updateStatus(Request $request, $id)
    {
        $contact = \App\Models\Contact::findOrFail($id);
        $contact->update(['status' => $request->status]);
        return redirect()->back()->with('success', 'Statut mis à jour !');
    }
    
    public function destroy($id)
    {
        $contact = \App\Models\Contact::findOrFail($id);
        $contact->delete();
        return redirect()->back()->with('success', 'Message supprimé !');
    }
}
