<?php

namespace App\Http\Controllers;

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

class AboutUsController extends Controller
{
    public function __construct(ResponseRepository $response) {
        $this->response = $response;
        $this->ruleOne = [
            'header' => 'required',    //About Us title
            'header_description' => 'required',    //about us description
            'about_sub_title' => 'required',
        ];
        $this->ruleTwo= [
            'header_two' => 'required',      //  what we do title
            'header_description_two' => 'required',  //what we do desription
        ];
        $this->ruleThree= [
            'header_three' => 'required',
            'header_three_description' => 'required',
        ];
        $this->ruleFour= [
            'header_four' => 'required',
            'header_four_sub' => 'required',
            'header_four_description' => 'required',
        ];
        $this->ruleFive= [
            'header_five' => 'required',
            'header_five_description' => 'required',
        ];
        $this->ruleSix= [
            'header_six' => 'required',
        ];

        $this->ruleSeven= [
            'social_title' => 'required',
        ];
        $this->ruleEight= [
            'calender_title' => 'required',
        ];

        $this->ruleNine= [
            'footer_about' => 'required',
        ];
    }

    public function getHomePageTitles() {
        return $this->response->jsonResponse(false, "About Us Content Fetched Successfully", AboutUs::all(), 550);
    }

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

    public function updateContentTwo(Request $request) {
        $validate = $this->response->validate($request->all(), $this->ruleTwo);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message(' Content', 'update'), AboutUs::first()->update($request->all()), 552);
        } else {
            return $this->response->jsonResponse(true, ' Content Update Failed', $validate, 554);
        }
    }

    public function updateContentThree(Request $request) {
        $validate = $this->response->validate($request->all(), $this->ruleThree);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Content', 'update'), AboutUs::first()->update($request->all()), 553);
        } else {
            return $this->response->jsonResponse(true, 'Content Update Failed', $validate, 554);
        }
    }

    public function updateContentFour(Request $request) {
        $validate = $this->response->validate($request->all(), $this->ruleFour);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Content', 'update'), AboutUs::first()->update($request->all()), 554);
        } else {
            return $this->response->jsonResponse(true, 'Content Update Failed', $validate, 554);
        }
    }

    public function updateContentFive(Request $request) {
        $validate = $this->response->validate($request->all(), $this->ruleFive);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Content', 'update'), AboutUs::first()->update($request->all()), 554);
        } else {
            return $this->response->jsonResponse(true, 'Content Update Failed', $validate, 554);
        }
    }

    public function updateContentSix(Request $request) {
        $validate = $this->response->validate($request->all(), $this->ruleSix);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Content', 'update'), AboutUs::first()->update($request->all()), 554);
        } else {
            return $this->response->jsonResponse(true, 'Content Update Failed', $validate, 554);
        }
    }

    public function updateContentSeven(Request $request) {
        $validate = $this->response->validate($request->all(), $this->ruleSeven);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Content', 'update'), AboutUs::first()->update($request->all()), 554);
        } else {
            return $this->response->jsonResponse(true, 'Content Update Failed', $validate, 554);
        }
    }

    public function updateContentEight(Request $request) {
        $validate = $this->response->validate($request->all(), $this->ruleEight);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Content', 'update'), AboutUs::first()->update($request->all()), 554);
        } else {
            return $this->response->jsonResponse(true, 'Content Update Failed', $validate, 554);
        }
    }

    public function updateContentNine(Request $request) {
        $validate = $this->response->validate($request->all(), $this->ruleNine);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Content', 'update'), AboutUs::first()->update($request->all()), 554);
        } else {
            return $this->response->jsonResponse(true, 'Content Update Failed', $validate, 554);
        }
    }
}
