-
Notifications
You must be signed in to change notification settings - Fork 241
/
ZiggyServiceProvider.php
42 lines (35 loc) · 1.21 KB
/
ZiggyServiceProvider.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
<?php
namespace Tightenco\Ziggy;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Illuminate\View\Compilers\BladeCompiler;
class ZiggyServiceProvider extends ServiceProvider
{
public function boot()
{
Route::macro('blacklist', function ($group = null) {
return Macro::blacklist($this, $group);
});
Route::macro('whitelist', function ($group = null) {
return Macro::whitelist($this, $group);
});
if ($this->app->resolved('blade.compiler')) {
$this->registerDirective($this->app['blade.compiler']);
} else {
$this->app->afterResolving('blade.compiler', function (BladeCompiler $bladeCompiler) {
$this->registerDirective($bladeCompiler);
});
}
if ($this->app->runningInConsole()) {
$this->commands([
CommandRouteGenerator::class,
]);
}
}
protected function registerDirective(BladeCompiler $bladeCompiler)
{
$bladeCompiler->directive('routes', function ($group) {
return "<?php echo app('" . BladeRouteGenerator::class . "')->generate({$group}); ?>";
});
}
}