<?php

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
use Laravel\Nova\Nova;
use Laravel\Nova\NovaApplicationServiceProvider;

use Illuminate\Http\Request;
use Laravel\Nova\Dashboards\Main;
use Laravel\Nova\Menu\Menu;
use Laravel\Nova\Menu\MenuItem;
use Laravel\Nova\Menu\MenuGroup;
use Laravel\Nova\Menu\MenuSection;
use Illuminate\Support\Facades\Blade;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();
        Nova::style('custom', public_path('css/custom.css'));
        Nova::footer(function ($request) {
            return Blade::render(config('app.name'));
        });

        Nova::mainMenu(function (Request $request) {
            return [
                MenuSection::dashboard(Main::class)->icon('chart-pie'),

                // MenuSection::make('Master Data', [                                    
                //     MenuItem::resource(\App\Nova\User::class), 
                // ])->icon('user-group')->collapsable(),


                //MenuSection::resource(\App\Nova\Tags::class)->icon('document-text'),
                MenuSection::resource(\App\Nova\Banner::class)->icon('photograph'),
                MenuSection::resource(\App\Nova\Article::class)->icon('document-text'),
                MenuSection::resource(\App\Nova\Videos::class)->icon('document-text'),
                MenuSection::make('Product', [
                    MenuItem::resource(\App\Nova\BannerProduct::class),
                    MenuItem::resource(\App\Nova\Category::class),
                    MenuItem::resource(\App\Nova\Product::class),
                ])->icon('document-text')->collapsable(),
                MenuSection::make('Hosea', [
                    MenuItem::resource(\App\Nova\Hosea::class),
                    MenuItem::resource(\App\Nova\City::class),
                ])->icon('document-text')->collapsable(),
                MenuSection::resource(\App\Nova\User::class)->icon('user-group'),
            ];
        });
    }

    /**
     * Register the Nova routes.
     *
     * @return void
     */
    protected function routes()
    {
        Nova::routes()
            ->withAuthenticationRoutes()
            ->withPasswordResetRoutes()
            ->register();
    }

    /**
     * Register the Nova gate.
     *
     * This gate determines who can access Nova in non-local environments.
     *
     * @return void
     */
    protected function gate()
    {
        Gate::define('viewNova', function ($user) {
            return in_array($user->email, [
                $user->email
            ]);
        });
    }

    /**
     * Get the dashboards that should be listed in the Nova sidebar.
     *
     * @return array
     */
    protected function dashboards()
    {
        return [
            new \App\Nova\Dashboards\Main,
        ];
    }

    /**
     * Get the tools that should be listed in the Nova sidebar.
     *
     * @return array
     */
    public function tools()
    {
        return [];
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}