<?php

namespace App\Providers;

use App\Nova\Dashboards\Main;
use App\Policies\PermissionsPolicy;
use App\Policies\RolesPolicy;
use Illuminate\Support\Facades\Gate;
use Laravel\Nova\Nova;
use Laravel\Nova\NovaApplicationServiceProvider;
use PhpJunior\NovaLogViewer\Tool;
use Spatie\Permission\Models\Permission;

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

//        Nova::enableRTL();

    }

    /**
     * Get the tools that should be listed in the Nova sidebar.
     *
     * @return array
     */
    public function tools()
    {
        return [
            \Vyuldashev\NovaPermission\NovaPermissionTool::make()
                ->rolePolicy(RolesPolicy::class)
                ->permissionPolicy(PermissionsPolicy::class),
                new Tool(),
            new \Llaski\NovaScheduledJobs\NovaScheduledJobsTool,

        ];
    }

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

    /**
     * Register any application services.
     *
     * @return void
     */
    public function 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 $user->hasAnyPermission(Permission::all());
        });
    }
    public function cards()
    {
        return [
            // ...
            new \Llaski\NovaScheduledJobs\NovaScheduledJobsCard,
        ];
    }
    /**
     * Get the dashboards that should be listed in the Nova sidebar.
     *
     * @return array
     */
    protected function dashboards()
    {
        return [
            new Main,
        ];
    }
}
