Skip to content

Instantly share code, notes, and snippets.

@harikt

harikt/hello.blade.php

Last active Sep 17, 2017
Embed
What would you like to do?
How can we extend Blade ?
I am using the directive https://laravel.com/docs/5.5/blade#extending-blade
@url('article_show', ['id' => '3'], ['foo' => 'bar'], 'fragment')
Problem is the rest of the params after string `'article_show'` is not received on call back.
I am trying to do something similar to : https://zendframework.github.io/zend-expressive/features/template/twig/
{{ path('article_show', {'id': '3'}) }}
which generates: /article/3
$urlHelperFactory = new UrlHelperFactory();
$urlHelper = $urlHelperFactory($container);
$viewResolver->resolve('blade')->getCompiler()->directive('url', function (
$routeName = null,
array $routeParams = [],
array $queryParams = [],
$fragmentIdentifier = null,
array $options = []
) use ($urlHelper) {
// this works fine
return $urlHelper->generate('article_show', ['id' => '3'], ['foo' => 'bar'], 'fragment');
// this breaks for the params are not received as expected.
// return $urlHelper->generate($routeName, $routeParams, $queryParams, $fragmentIdentifier, $options);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment