Skip to content

Commit

Permalink
Merge pull request #267 from axlon/after-resolving
Browse files Browse the repository at this point in the history
Utilize afterResolving for Laravel 6.10 and up
  • Loading branch information
bakerkretzmar committed May 8, 2020
2 parents c77f169 + 76ac1bc commit ace6f4c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/ZiggyServiceProvider.php
Expand Up @@ -18,14 +18,25 @@ public function boot()
return Macro::whitelist($this, $group);
});

$this->app['blade.compiler']->directive('routes', function ($group) {
return "<?php echo app('" . BladeRouteGenerator::class . "')->generate({$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}); ?>";
});
}
}

0 comments on commit ace6f4c

Please sign in to comment.