<?php

namespace App\Http\Controllers\BackOffice\Settings;

use Illuminate\View\View;
use Illuminate\Http\Request;
use App\Http\Requests\ColorRequest;
use App\Http\Controllers\Controller;
use App\Services\Settings\ColorService;

class ColorController extends Controller
{
    public function __construct(
        private readonly ColorService $colorservice,
    ) {
    }

    /** Show Color
     * @param Request $request
     * 
     * @return View
     */
    public function index(Request $request): View
    {   
        //Breadcrumb
        $breadcrumb = [
            'paramètres',
            'couleur',
        ];
        // Return a view
        return view('backoffice.settings.color.index' , [
            'title' => 'Couleur',
            'breadcrumb' => $breadcrumb,
        ]);

    }


    /** Display Form Content
     * @param Request $request
     * 
     * @return mixed
     */
    public function showForm(Request $request) :mixed
    {
        // Return form content
        return $this->colorservice->_showForm((int)$request->rowID);
    }

    /** Get data
     * @return array
     */
    public function getData(): array
    {   
        // Return permissions data
        return $this->colorservice->_getData();
    }

    /**
     * @param ColorRequest $request
     * 
     * @return string
     */
    public function setData(ColorRequest $request): string
    {  
        $response =  $this->colorservice->_setData($request->all());
        return json_encode($response);
    }

    /**
     * @param Request $request
     * 
     * @return string
     */
    public function deleteData(Request $request): string
    {
        $response =  $this->colorservice->_deleteData((int)$request->rowID);
        return json_encode($response);
    }
}
