<?php

namespace Modules\Slider\Controllers\Api;

/** Ajax Request */

use App\Services\Response\ResponseService;
use Exception;
use Illuminate\View\View;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Redirector;
use Illuminate\Http\RedirectResponse;
use App\Http\Controllers\Controller;
use Modules\Slider\Models\Slider;
use Modules\Slider\Models\Resources\SliderResource;
use Modules\Slider\Services\SliderService;

class SliderController extends Controller
{
    
    private SliderService $sliderService;

    public function __construct(SliderService $sliderService)
    {
        $this->sliderService = $sliderService;
    }

    /**
     * Display a listing of the faqs.
     *
     * @param Request $request
     * @return View
     */
    public function index(Request $request) :JsonResponse
    {
        $sliders = $this->sliderService->get($request);
        $sliders = SliderResource::collection($sliders);
        $response = [
            'status'=>200,
            'message'=>'',
            'data'=> $sliders
        ];
        return ResponseService::response($response);
    }

}
