/**
* Bootstrap any application services.
*/
public function boot()
{
\Blade::directive('macro', function ($expression) {
$pattern = '/(\\([\'|\\"](\\w+)[\'|\\"],\\s*(([^\\@])+|(.*))\\))/xim';
$matches = [];
preg_match_all($pattern, $expression, $matches);
if (!isset($matches[3][0])) {
throw new \InvalidArgumentException(sprintf('Invalid arguments in blade: macro%s', $expression));
}
return sprintf("<?php \$___tiny['%s']=function(%s){ ob_start(); ?>\n", $matches[2][0], $matches[3][0]);
});
\Blade::directive('endmacro', function ($expression) {
return "\n<?php return ob_get_clean();} ?>\n";
});
\Blade::directive('usemacro', function ($expression) {
$pattern = '/(\\([\'|\\"](\\w+)[\'|\\"],\\s*(([^\\@])+|(.*))\\))/xim';
$matches = [];
preg_match_all($pattern, $expression, $matches);
if (!isset($matches[3][0])) {
throw new \InvalidArgumentException(sprintf('Invalid arguments in blade: usemacro%s', $expression));
}
return sprintf("<?php echo \$___tiny['%s'](%s); ?>\n", $matches[2][0], $matches[3][0]);
});
\Blade::directive('permission', function ($expression) {
return "<?php if(Auth::user()->permission{$expression}): ?>";
});
\Blade::directive('endpermission', function ($expression) {
return '<?php endif; ?>';
});
}