<?php

namespace App\Http\Controllers;

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

class FounderController extends Controller
{
    public function __construct(ResponseRepository $response) {
        $this->response = $response;
        $this->storeRules = [
            'title' => 'required',
            'description' => 'required',
            'founder_name_one' => 'required',
            'founder_role_one' => 'required',
            'founder_name_two' => 'required',
            'founder_role_two' => 'required',
        ];
    }

    public function getFounder() {
        return $this->response->jsonResponse(false, "Founder Content Fetched Successfully", Founder::all(), 200);
    }

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