<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Admin\NavigationMenu;
use App\Models\Admin\Page;

class NavigationMenuController extends Controller
{
    public function index(?int $id = null)
    {
        if($id === null){
            return view('admin.navigation.menu.index');
        }else{
            if($id === 0){
                $navigationPages = Page::where('display_in_navigation', 1)->get();

                return view('admin.navigation.menu.index', [
                    'navigationPages' => $navigationPages
                ]);
            }else{
                $navigationMenu = NavigationMenu::findOrFail($id);
                return view('admin.navigation.menu.index', [
                    'navigationMenu' => $navigationMenu
                ]);
            }
        }
    }

    public function create()
    {
        return view('admin.navigation.menu.create');
    }

    public function edit(int $id)
    {
        $navigationMenu = NavigationMenu::findOrFail($id);

        return view('admin.navigation.menu.edit', [
            'navigationMenu' => $navigationMenu
        ]);
    }
}
