<?php

namespace App\Http\Controllers;

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

class WhyKarthikController extends Controller
{
    //

    
    public function __construct(ResponseRepository $response) {
        $this->response = $response;
        $this->storeRules = [
            'why_karthik_title' => 'required',
            'why_karthik_description' => 'required',
        ];
    }
    public function getWhyKarthik() {
        return $this->response->jsonResponse(false, "Why Karthik Content Fetched Successfully", WhyKarthik::all(), 550);
    }
    public function updateWhyKarthik(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRules);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Why Karthik Content', 'update'), WhyKarthik::first()->update($request->all()), 551);
        } else {
            return $this->response->jsonResponse(true, 'Why Karthik Content Update Failed', $validate, 552);
        }
    }
}
