<?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->storeRules = [
            'phone_one' => 'required',
            'phone_two' => 'required',
            'phone_three' => 'required',
            'email_one' => 'required',
            'email_two' => 'required',
        ];
    }

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

    public function updateContact(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRules);
        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);
        }
    }
}
