<?php

namespace App\Http\Controllers;
use App\Models\FooterBlock;
use App\Models\ConsultUs;
use Illuminate\Http\Request;
use App\Repositories\ResponseRepository;

class FooterBlockController extends Controller
{
    public function __construct(ResponseRepository $response) {
        $this->response = $response;
        $this->storeRules = [
            'phone_number' => 'required',
            'email' => 'required',
            'insta_link' => 'required',
            'facebook_link' => 'required',
            'address' => 'required',
            'twitter' => 'required',
            'linkedin' => 'required',
            'marque' => 'required',

        ];
        $this->storeRulesTwo = [
            'contact_heading_one' => 'required',
            'contact_heading_two' => 'required',
            'quiks_link_title' => 'required',
            'maps_title' => 'required',
        ];
        
    }
    // Data Get Function
    public function getFooterBlock() {
        return $this->response->jsonResponse(false, "Social Link Details Fetched Successfully", FooterBlock::all(), 200);
    }
    // data Update Function
    public function updateFooterBlock(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRules);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Social Link Details', 'update'), FooterBlock::first()->update($request->all()), 200);
        } else {
            return $validate;
        }
    }
    // Data Update Function
    public function updateContactPageSideheading(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRulesTwo);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Side Heading Details', 'update'), FooterBlock::first()->update($request->all()), 200);
        } else {
            return $validate;
        }
    }
    
}
