<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Contact;
use Illuminate\Http\Request;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Hash;
use Carbon\Carbon;
use DB;
use Auth;

class ContactController extends Controller
{
    public function index()
    {
        $contacts = Contact::orderBy('created_at', 'desc')->get();
        return view('admin.contacts.index', compact('contacts'));
       
    }

    public function contact_view(Request $request)
    {
        $id = $request->id; 
    
        // try {
            $contactview = Contact::findOrFail($id);
            return response()->json(['data'=>$contactview]);
    
        // } catch (\Exception $e) {
        //     return redirect()->back()->with('error', 'contact not found.');
        // }
    }
}
