@use('App\Models\Services')
@use('App\Models\Companyarticles')

<header id="masthead" class="site-header clearfix">

    <div class="header-main clearfix">
        <div class="container mobile_relative">
            <div class="row">
                <div class="site-logo col-md-2 col-sm-6 col-xs-6">
                    <a href="{{ route('home') }}" class="logo">
                        <img src="<?php echo base_url(SITEVARS->primary_logo); ?>" alt="{{ SITEVARS->title }}" class="logo-light show-logo">
                        <img src="<?php echo base_url(SITEVARS->secondary_logo); ?>" alt="{{ SITEVARS->title }}" class="logo-dark hide-logo">
                    </a>
                    <h1 class="site-title"><a href="{{ route('home') }}">{{ SITEVARS->title }}</a></h1>
                </div>
                <div class="site-menu col-md-9 col-sm-6 col-xs-6">
                    <nav id="site-navigation" class="main-nav primary-nav nav">
                        @if ($headerMenuItems->isNotEmpty())
                            <ul class="menu">
                                @foreach ($headerMenuItems as $menuItem)
                                    @switch ($menuItem->type)
                                        @case ('tbl_articles')
                                            @php $menuItem->link = route('profile.single', ['parent'=>'article','alias'=> Articles::find($menuItem->ref)->alias]); @endphp
                                        @break

                                        @case ('tbl_franchises')
                                            @php $menuItem->link = route('showFranchise', Franchises::find($menuItem->ref)->alias); @endphp
                                        @break

                                        @case ('tbl_services')
                                            @php $menuItem->link = route('showService', Services::find($menuItem->ref)->alias); @endphp
                                        @break

                                        @case ('single_link')
                                            @php $menuItem->link = config('app.url') . $menuItem->ref; @endphp
                                        @break

                                        @default
                                            @php $menuItem->link = config('app.url') . $menuItem->ref; @endphp
                                        @break
                                    @endswitch


                                    @if ($menuItem->children->isNotEmpty())
                                        <li class="has-dropdown">
                                            <a class="dropdown-toggle"
                                                href="javascript:void(0)">{{ $menuItem->title }}</a>
                                            <ul class="submenu">
                                                @foreach ($menuItem->children as $subMenu)
                                                    @switch($subMenu->type)
                                                        @case ('tbl_news')
                                                            @php $subMenu->link = route('showNews', News::find($subMenu->ref)->alias); @endphp
                                                        @break

                                                        @case ('tbl_franchises')
                                                            @php $subMenu->link = route('showFranchise', Franchises::find($subMenu->ref)->alias); @endphp
                                                        @break

                                                        @case ('tbl_companyarticles')
                                                            @php $subMenu->link = route('article.single', Companyarticles::find($subMenu->ref)->alias); @endphp
                                                        @break

                                                        @case ('tbl_services')
                                                            @php $subMenu->link = route('showService', Services::find($subMenu->ref)->alias); @endphp
                                                        @break

                                                        @default
                                                            @php $subMenu->link = config('app.url') . $subMenu->ref; @endphp
                                                        @break
                                                    @endswitch
                                                    <li class="nav-item">
                                                        <a href="{{ $subMenu->link }}"
                                                            class="nav-link">{{ $subMenu->title }}</a>
                                                    </li>
                                                @endforeach
                                            </ul>
                                        </li>
                                    @else
                                        <li><a @if ($menuItem->title == 'Quote') class = "fh-btn btn" style="color:white;" @endif
                                                href="{{ $menuItem->link }}">{{ $menuItem->title }}</a></li>
                                    @endif
                                @endforeach
                            </ul>
                        @endif

                    </nav>
                </div>
                {{-- <div class="col-xl-3 col-lg-3 col-md-3">
                    <div class="headerarea__right">
                        <div class="headerarea__button">
                            <a href="{{ route('contact') }}">Contact Us</a>
                        </div>
                    </div>
                </div> --}}
            </div>
            {{-- <a href="#" class="navbar-toggle">
                <span class="navbar-icon">
                    <span class="navbars-line"></span>
                </span>
            </a> --}}
        </div>
    </div>

</header>