<?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->storeRulesHomePageContent = [
            'header' => 'required',
            'home_about_description' => 'required',
        ];
    }

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

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