<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Mtc\MercuryDataModels\VehicleModel;

class ModelController extends Controller
{
    /**
     * Display a listing of body vehicle model
     *
     * @param Request $request
     * @param int $make_id
     * @return Response
     */
    public function index(Request $request, $make_id): Response
    {
        return response([
            'data' => VehicleModel::query()
                ->with('filterIndex')
                ->ofMake($make_id)
                ->when($request->input('type'), fn($query, $type) => $query->where('type', $type))
                ->orderBy('name')
                ->get()
        ]);
    }

    /**
     * Display the specified vehicle model.
     *
     * @param  VehicleModel $model
     * @return VehicleModel
     */
    public function show(VehicleModel $model)
    {
        return $model;
    }
}
