<?php

namespace App\Http\Controllers;

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


class CortenController extends Controller
{
    public function __construct(ResponseRepository $response) {
        $this->response = $response;
        $this->storeRules = [
            'corten_title' => 'required',
            'corten_description' => 'required',
        ];
        $this->storeRulesOne = [
            'why_choose_head' => 'required',
        ];

        $this->storeRulesTwo = [
            'why_karthik_title' => 'required',
            'why_karthik_description' => 'required',
        ];
        $this->storeRulesThree = [
            'corten_industries_title' => 'required',
            'corten_industries_description' => 'required',
        ];

        $this->storeRulesFour = [
            'manufacturer_title' => 'required',
            'manufacturer_description' => 'required',
        ];
        $this->storeRulesFive = [
            'exporter_title' => 'required',
            'exporter_description' => 'required',
        ];
    }

    public function getCorten() {
        return $this->response->jsonResponse(false, "Corten Content Fetched Successfully", Corten::all(), 550);
    }

    public function updateCorten(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRules);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Corten Content', 'update'), Corten::first()->update($request->all()), 551);
        } else {
            return $this->response->jsonResponse(true, 'Corten Content Update Failed', $validate, 552);
        }
    }
    public function updateCartenWhyChoose(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRulesOne);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Corten Content', 'update'), Corten::first()->update($request->all()), 551);
        } else {
            return $this->response->jsonResponse(true, 'Corten Content Update Failed', $validate, 552);
        }
    }

    public function updateCartenWhykarthik(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRulesTwo);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Corten Content', 'update'), Corten::first()->update($request->all()), 551);
        } else {
            return $this->response->jsonResponse(true, 'Corten Content Update Failed', $validate, 552);
        }
    }
    public function updateCartenIndustries(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRulesThree);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Corten Content', 'update'), Corten::first()->update($request->all()), 551);
        } else {
            return $this->response->jsonResponse(true, 'Corten Content Update Failed', $validate, 552);
        }
    }

    public function updateManufacturer(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRulesFour);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Corten Content', 'update'), Corten::first()->update($request->all()), 551);
        } else {
            return $this->response->jsonResponse(true, 'Corten Content Update Failed', $validate, 552);
        }
    }
    public function updateExporter(Request $request) {
        $validate = $this->response->validate($request->all(), $this->storeRulesFive);
        if($validate === true) {
            return $this->response->jsonResponse(false, $this->response->message('Corten Content', 'update'), Corten::first()->update($request->all()), 551);
        } else {
            return $this->response->jsonResponse(true, 'Corten Content Update Failed', $validate, 552);
        }
    }


}
