<?php

namespace App\Http\Controllers;

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

class HomeAboutController extends Controller
{
    public function __construct(ResponseRepository $response) {
        $this->response = $response;
        $this->ruleOne = [
            'home_about_title' => 'required' ,
            'home_about_description' => 'required',
            'home_about_link' => 'required',
        ];
    }
    // Get All Data Function
    public function getAllHomeAboutDetailsData() {
        return $this->response->jsonResponse(false, "Home About Content Fetched Successfully", HomeAbout::all(), 550);
    }
    // Update Data Function
    public function updateHomeAboutSection(Request $request) {
        $validate = $this->response->validate($request->all(), $this->ruleOne);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Content', 'update'), HomeAbout::first()->update($request->all()), 551);
        } else {
            return $this->response->jsonResponse(true, 'Content Update Failed', $validate, 552);
        }
    }
    
}
