<?php

namespace App\Http\Controllers;

use App\Facades\LeaseVehicleFilter;
use App\Facades\StockAndOfferFilter;
use Illuminate\Http\Response;
use Mtc\Filter\Facades\Filter;

class FilterController extends Controller
{
    /**
     * Vehicle search filter endpoint
     *
     * @return array|Response
     */
    public function index()
    {
        $result = Filter::handle();
        if (!empty($result['type']) && $result['type'] === 'redirect') {
            return response($result, 404);
        }
        return $result;
    }

    /**
     * Vehicle search filter endpoint
     *
     * @return array
     */
    public function leaseVehicleIndex()
    {
        return LeaseVehicleFilter::handle();
    }

    /**
     * Vehicle search via widget
     *
     * @return array
     */
    public function widget()
    {
        return Filter::handleWidget();
    }

    /**
     * @param Request $request
     * @return array
     */
    public function filterStockAndOffers(): array
    {
        return StockAndOfferFilter::handle();
    }
}
