<?php

namespace App\Providers;

use App\Nova\Article;
use App\Nova\Category;
use App\Nova\Contact;
use App\Nova\Dashboards\Main;
use App\Nova\Referral;
use App\Nova\Tag;
use App\Nova\Testimonial;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use Laravel\Nova\Menu\MenuItem;
use Laravel\Nova\Menu\MenuSection;
use Laravel\Nova\Nova;
use Laravel\Nova\NovaApplicationServiceProvider;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();

        Nova::mainMenu(function (Request $request) {
            return [
                MenuSection::dashboard(new Main())->icon('view-grid'),

                MenuSection::make('Blogs', [
                    MenuItem::resource(Article::class),
                    MenuItem::resource(Category::class),
                    MenuItem::resource(Tag::class),
                ])->icon('chat-alt')->collapsable(),

                MenuSection::make('Management', [
                    MenuItem::resource(Contact::class),
                    MenuItem::resource(Referral::class),
                    MenuItem::resource(Testimonial::class),
                ])->icon('user-group')->collapsable(),
            ];
        });
    }

    /**
     * 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, [
                'hello.sumangrg@gmail.com',
                'businessbasket2021@gmail.com',
                'sanish@gmail.com',
                'ayushagrg002@gmail.com',
            ]);
        });
    }

    /**
     * Get the cards that should be displayed on the default Nova dashboard.
     *
     * @return array
     */
    protected function cards()
    {
        return [

        ];
    }

    /**
     * Get the extra dashboards that should be displayed on the Nova dashboard.
     *
     * @return array
     */
    protected function dashboards()
    {
        return [
            new 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()
    {
        //
    }
}
