<?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->storeRules = [
            'header_one' => 'required',
            'header_two' => 'required',
            'description_one' => 'required',
            'description_two' => 'required'
        ];
    }

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

    public function updateAboutUs(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRules);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('About Us', 'update'), AboutUs::first()->update($request->all()), 200);
        } else {
            return $this->response->jsonResponse(true, 'About Us Update Failed', $validate, 201);
        }
    }
}
