| 1 | <?php namespace Blok\JavaScript; |
||||
| 2 | |||||
| 3 | use Illuminate\Support\Facades\Blade; |
||||
| 4 | use Illuminate\Support\ServiceProvider; |
||||
| 5 | |||||
| 6 | class JavaScriptServiceProvider extends ServiceProvider |
||||
| 7 | { |
||||
| 8 | protected $defer = false; |
||||
| 9 | |||||
| 10 | public function register() |
||||
| 11 | { |
||||
| 12 | $this->app->singleton('JavaScript', function ($app) { |
||||
| 13 | return new JavaScript(config('javascript.namespace')); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 14 | }); |
||||
| 15 | } |
||||
| 16 | |||||
| 17 | public function boot() |
||||
| 18 | { |
||||
| 19 | require_once __DIR__ . '/helpers.php'; |
||||
| 20 | |||||
| 21 | $this->publishes([ |
||||
| 22 | __DIR__ . '/config/javascript.php' => config_path('javascript.php'), |
||||
|
0 ignored issues
–
show
The function
config_path was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 23 | ], 'config'); |
||||
| 24 | |||||
| 25 | /** |
||||
| 26 | * @example |
||||
| 27 | * @javascript($namespace, (optional) $array) |
||||
| 28 | */ |
||||
| 29 | Blade::directive('javascript', function ($expression) { |
||||
| 30 | return "<?php echo JavaScript::render({$expression}); ?>"; |
||||
| 31 | }); |
||||
| 32 | } |
||||
| 33 | } |