HEX
Server: LiteSpeed
System: Linux sv4.hami.host 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User: armgroup (1008)
PHP: 8.2.32
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open, mail, socket_create, socket_create_listen, socket_create_pair, link, dl, openlog, syslog, stream_socket_server, curl_multi_init
Upload Files
File: /home/armgroup/libs/packages/consoletvs/charts/src/ChartsServiceProvider.php
<?php

declare(strict_types=1);

namespace ConsoleTVs\Charts;

use Illuminate\Contracts\Config\Repository;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\Registrar as RouteRegistrar;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;

class ChartsServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        // Merge the configuration files.
        $this->mergeConfigFrom(__DIR__.'/Config/charts.php', 'charts');
        // Register the Chart Registerer singleton class to avoid resolving it
        // multiple times in the application.
        $this->app->singleton(Registrar::class, fn (Application $app) => new Registrar(
            $app,
            $app->make(Repository::class),
            $app->make(RouteRegistrar::class)
        ));
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(Repository $config, Registrar $charts): void
    {
        // Publish the configuration file to the config path.
        $this->publishes([__DIR__.'/Config/charts.php' => config_path('charts.php')], 'charts');
        // Create the blade directrives
        $routeNamePrefix = $config->get('charts.global_route_name_prefix');
        Blade::directive('chart', function ($expression) use ($routeNamePrefix) {
            return "<?php echo route('{$routeNamePrefix}.'.{$expression}); ?>";
        });
        // Register the console commands.
        if ($this->app->runningInConsole()) {
            $this->commands([Commands\CreateChart::class]);
        }
    }
}