<?php

namespace App\Http\Controllers;

use App\Models\Domain;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class MenuController extends Controller
{
    public function index($domain = null)
    {
        $domain = Domain::query()->with([
            'user',
            'user.categories',
            'user.categories.foods'
        ])->where('domain', $domain ?? '192.168.1.101')->first();

        $template = $domain->user->template;

        if(!$domain){
            throw new NotFoundHttpException();
        }

        return view("food-menu/{$template}/theme", [
            'domain' => $domain
        ]);
    }
}
