<?php

namespace App\Http\Controllers;

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

class HomePageTitleController extends Controller
{
    public function __construct(ResponseRepository $response) {
        $this->response = $response;
        $this->storeRules = [
            'title_one' => 'required',
            'title_two' => 'required',
            'title_three' => 'required',
            'title_four' => 'required',
            'video_one' => 'required',
            'video_two' => 'required',
        ];
    }

    public function getHomePageTitle() {
        return $this->response->jsonResponse(false, "Home Page Details Fetched Successfully", HomePageTitle::all(), 200);
     }

    public function updateHomePageTitle(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRules);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Home Page Details', 'update'), HomePageTitle::first()->update($request->all()), 200);
        } else {
            return $this->response->jsonResponse(true, 'Home Page Details Update Failed', $validate, 201);
        }
    }
}
