<?php

namespace Tricks\LaravelTools;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use Laravel\Nova\Dashboard;
use Laravel\Nova\LogViewer\LogViewer;
use Laravel\Nova\Nova;
use Laravel\Nova\NovaApplicationServiceProvider;
use Laravel\Nova\Tool;
use Tricks\Dashboard\Main;

class LaravelToolsNovaServiceProvider extends NovaApplicationServiceProvider
{
    public function boot(): void
    {
        parent::boot();
        Nova::withoutNotificationCenter();

        Nova::footer(fn () => '<p class="text-center">tricks GmbH</p>'
            .'<p class="text-center"><a class="link-default" href="mailto:hello@tricks.de">hello@tricks.de</a></p>');

    }

    /**
     * @return array<int,Tool>
     */
    public function tools(): array
    {
        return [
            LogViewer::make()->canSee(fn (Request $request) => $request->user()->admin ?? false),
        ];
    }

    protected function routes(): void
    {
        Nova::routes()
            ->withAuthenticationRoutes()
            ->withPasswordResetRoutes()
            ->register();
    }

    protected function gate(): void
    {
        Gate::define('viewNova', fn ($user) => true);
    }

    /**
     * @return array<int,Dashboard>
     */
    protected function dashboards(): array
    {
        return [
            Main::make(),
        ];
    }
}
