<?php

namespace App\Http\Controllers\BackOffice\Settings;

use Illuminate\View\View;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests\TransmissionTypeRequest;
use App\Services\Settings\TransmissionTypeService;

class TransmissionTypeController extends Controller
{
    public function __construct(
        private readonly TransmissionTypeService $transmissiontypeservice,
    ) {
    }

    /** Show Brand
     * @param Request $request
     * 
     * @return View
     */
    public function index(Request $request): View
    {   
        //Breadcrumb
        $breadcrumb = [
            'paramètres',
            'type de transmission',
        ];
        // Return a view
        return view('backoffice.settings.transmissiontype.index' , [
            'title' => 'Type de transmission',
            'breadcrumb' => $breadcrumb,
        ]);

    }


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

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

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

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