<?php

namespace App\Http\Controllers;


use Illuminate\Http\Request;
use App\Models\ContactDetails;
use App\Repositories\ResponseRepository;
use Illuminate\Support\Facades\Log;


class ContactDetailsController extends Controller
{
    //
    public function __construct(ResponseRepository $response) {
        $this->response = $response;
        $this->ruleOne = [
            'title' => 'nullable',
            'description' => 'nullable',
        ];
    }    

    public function getContactDetailsTitles() {
        return $this->response->jsonResponse(false, "Contact Details  Fetched Successfully", ContactDetails::all(), 550);
    }

    public function updateContactDetailsTitles(Request $request) {
        $validate = $this->response->validate($request->all(), $this->ruleOne);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Contact Details', 'update'), ContactDetails::first()->update($request->all()), 551);
        } else {
            return $this->response->jsonResponse(true, 'Contact Details Update Failed', $validate, 552);
        }
    }
}
