-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathProvider.php
45 lines (37 loc) · 1.35 KB
/
Provider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Akaunting\Apexcharts;
use Akaunting\Apexcharts\Chart;
use Illuminate\Support\ServiceProvider;
use Illuminate\View\Compilers\BladeCompiler;
class Provider extends ServiceProvider
{
/**
* Register the application services.
*/
public function register(): void
{
$this->app->alias(Chart::class, 'apexcharts');
$this->mergeConfigFrom(__DIR__ . '/Config/apexcharts.php', 'apexcharts');
}
/**
* When this method is apply we have all laravel providers and methods available
*/
public function boot(): void
{
$this->loadViewsFrom(__DIR__ . '/Views', 'apexcharts');
$this->publishes([
__DIR__ . '/Config/apexcharts.php' => config_path('apexcharts.php'),
__DIR__ . '/Public' => public_path('vendor/apexcharts'),
__DIR__ . '/Views' => resource_path('views/vendor/apexcharts'),
], 'apexcharts');
$this->registerBladeDirectives();
}
public function registerBladeDirectives(): void
{
$this->callAfterResolving('blade.compiler', function (BladeCompiler $bladeCompiler) {
$bladeCompiler->directive('apexchartsScripts', function ($expression) {
return '{!! \Akaunting\Apexcharts\Chart::loadScript(' . $expression . ') !!}';
});
});
}
}