<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Libraries\Helper;
use App\Repositories\UserRepository;
use App\Repositories\ContactRepository;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;

class ContactController extends Controller
{
    public function index(Request $request)
    {
		$payload = $request->all();
    	$filters = ['page' => isset($payload['page']) && $payload['page'] ? $payload['page'] : 1];
        $data = Helper::preparePagePayload('Contact List');
        $data['contacts'] = ContactRepository::fetchItems($filters)->toArray();
        return view('admin.contact.index',$data);
    }

    public function deleteContact(Request $request)
    {
    	$payload = $request->all();
    	if(isset($payload['id']) && $payload['id']){
    		$status = ContactRepository::deleteContact($payload);
    		if($status){
    			return response()->json(['status' => true]);
    		}
    	}
    	return response()->json(['status' => false]);
    }
}
