<commit_before><?php

declare(strict_types=1);

// phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter,SlevomatCodingStandard.Functions.UnusedParameter

namespace App\Providers;

use App\Models\Travel;
use App\Models\TravelAssignment;
use App\Models\User;
use App\Nova\Cards\MakeAWish;
use App\Nova\Dashboards\Demographics;
use App\Nova\Dashboards\JEDI;
use App\Nova\Metrics\ActiveAttendanceBreakdown;
use App\Nova\Metrics\AttendancePerWeek;
use App\Nova\Metrics\DocumentsReceivedForTravel;
use App\Nova\Metrics\DuesRevenueByFiscalYear;
use App\Nova\Metrics\MembersByFiscalYear;
use App\Nova\Metrics\PaymentReceivedForTravel;
use App\Nova\Metrics\PaymentsPerDay;
use App\Nova\Metrics\TransactionsByDuesPackage;
use App\Nova\Metrics\TravelAuthorityRequestReceivedForTravel;
use App\Nova\Tools\AttendanceReport;
use Carbon\Carbon;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Str;
use Laravel\Nova\Events\ServingNova;
use Laravel\Nova\Nova;
use Laravel\Nova\NovaApplicationServiceProvider;
use Vyuldashev\NovaPermission\NovaPermissionTool;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        parent::boot();
        Nova::serving(static function (ServingNova $event): void {
            Nova::script('apiary-custom', asset('js/nova.js'));
            Nova::theme(asset('css/nova.css'));
        });
    }

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

    /**
     * Register the Nova gate.
     *
     * This gate determines who can access Nova in non-local environments.
     */
    protected function gate(): void
    {
        Gate::define('viewNova', static function (User $user): bool {
            return $user->can('access-nova');
        });
    }

    /**
     * Get the cards that should be displayed on the Nova dashboard.
     *
     * @return array<\Laravel\Nova\Card>
     */
    protected function cards(): array
    {
        if ('/nova-api/dashboards/main' !== $_SERVER['REQUEST_URI'] &&
            ! Str::startsWith($_SERVER['REQUEST_URI'], '/nova-api/metrics/')) {
            return [];
        }

        $cards = [
            (new PaymentsPerDay())->canSee(static function (Request $request): bool {
                return $request->user()->can('read-payments');
            }),
            (new MembersByFiscalYear())->canSee(static function (Request $request): bool {
                return $request->user()->can('read-dues-transactions');
            }),
            (new DuesRevenueByFiscalYear())->canSee(static function (Request $request): bool {
                return $request->user()->can('read-dues-transactions');
            }),
            (new AttendancePerWeek())->canSee(static function (Request $request): bool {<commit_msg>Use Laravel global helper for checking URI<commit_after><?php

declare(strict_types=1);

// phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter,SlevomatCodingStandard.Functions.UnusedParameter

namespace App\Providers;

use App\Models\Travel;
use App\Models\TravelAssignment;
use App\Models\User;
use App\Nova\Cards\MakeAWish;
use App\Nova\Dashboards\Demographics;
use App\Nova\Dashboards\JEDI;
use App\Nova\Metrics\ActiveAttendanceBreakdown;
use App\Nova\Metrics\AttendancePerWeek;
use App\Nova\Metrics\DocumentsReceivedForTravel;
use App\Nova\Metrics\DuesRevenueByFiscalYear;
use App\Nova\Metrics\MembersByFiscalYear;
use App\Nova\Metrics\PaymentReceivedForTravel;
use App\Nova\Metrics\PaymentsPerDay;
use App\Nova\Metrics\TransactionsByDuesPackage;
use App\Nova\Metrics\TravelAuthorityRequestReceivedForTravel;
use App\Nova\Tools\AttendanceReport;
use Carbon\Carbon;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Str;
use Laravel\Nova\Events\ServingNova;
use Laravel\Nova\Nova;
use Laravel\Nova\NovaApplicationServiceProvider;
use Vyuldashev\NovaPermission\NovaPermissionTool;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        parent::boot();
        Nova::serving(static function (ServingNova $event): void {
            Nova::script('apiary-custom', asset('js/nova.js'));
            Nova::theme(asset('css/nova.css'));
        });
    }

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

    /**
     * Register the Nova gate.
     *
     * This gate determines who can access Nova in non-local environments.
     */
    protected function gate(): void
    {
        Gate::define('viewNova', static function (User $user): bool {
            return $user->can('access-nova');
        });
    }

    /**
     * Get the cards that should be displayed on the Nova dashboard.
     *
     * @return array<\Laravel\Nova\Card>
     */
    protected function cards(): array
    {
        if (! request()->is('nova-api/dashboards/main') &&
            ! request()->is('nova-api/metrics/*')) {
            return [];
        }

        $cards = [
            (new PaymentsPerDay())->canSee(static function (Request $request): bool {
                return $request->user()->can('read-payments');
            }),
            (new MembersByFiscalYear())->canSee(static function (Request $request): bool {
                return $request->user()->can('read-dues-transactions');
            }),
            (new DuesRevenueByFiscalYear())->canSee(static function (Request $request): bool {
                return $request->user()->can('read-dues-transactions');
            }),
            (new AttendancePerWeek())->canSee(static function (Request $request): bool {
{'fraction_non_alphanumeric': 0.12854251012145748, 'fraction_numerical': 0.00033738191632928474, 'mean_word_length': 3.0917874396135265, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2871881', 'n_tokens_mistral': 1769, 'n_tokens_neox': 1761, 'n_words': 336}