<?php

namespace App\Services;

use App\Models\GenericBackoffice\Menu;
use App\Exceptions\ApiHttpException;
use App\Libs\Api\ParsedListParams;
use Illuminate\Database\Eloquent\Builder;
use App\Services\DataService;

class MenuDataService extends DataService
{

    /**
     * Finds the first defined menu 
     *
     * @throws ApiHttpException if no menu exists in the database
     * @return Menu
     */
    public function findFirst(): Menu
    {


        $menu = Menu::with('menuItems')->first();

        if (!$menu) {
            throw new ApiHttpException(404, 'item_not_found');
        }

        return $menu;
    }
}
