<?php

namespace App\Http\Controllers;

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

class HomeServiceController extends Controller
{
    //
    public function __construct(ResponseRepository $response) {
        $this->response = $response;
        $this->storeRules = [
            'service_main_header' => 'required',
        ];
        $this->storeRulesOne = [
            'home_hr_ttitle' => 'required',
            'home_hr_description' => 'required',
        ];
        $this->storeRulestwo = [
            'home_cr_ttitle' => 'required',
            'home_cr_description' => 'required',
        ];
    }
    public function getHomeService() {
        return $this->response->jsonResponse(false, "Home Service Content Fetched Successfully", HomeService::all(), 550);
    }
    public function updateHomeService(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRules);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Home Service Content', 'update'), HomeService::first()->update($request->all()), 551);
        } else {
            return $this->response->jsonResponse(true, 'Home Service Content Update Failed', $validate, 552);
        }
    }
    public function updateHomeHrDetails(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRulesOne);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Home Service Content', 'update'), HomeService::first()->update($request->all()), 551);
        } else {
            return $this->response->jsonResponse(true, 'Home Service Content Update Failed', $validate, 552);
        }
    }
    public function updateHomeCrDetails(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRulestwo);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Home Service Content', 'update'), HomeService::first()->update($request->all()), 551);
        } else {
            return $this->response->jsonResponse(true, 'Home Service Content Update Failed', $validate, 552);
        }
    }
}
