Skip to content

Commit

Permalink
Support older versions as well
Browse files Browse the repository at this point in the history
  • Loading branch information
arrilot committed Aug 24, 2016
1 parent 8a30b25 commit 336f456
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,24 @@ public function boot()
});
}

Blade::directive('widget', function ($expression) {
return "<?php echo app('arrilot.widget')->run({$expression}); ?>";
$omitParenthesis = version_compare($this->app->version(), '5.3', '<');

Blade::directive('widget', function ($expression) use ($omitParenthesis) {
$expression = $omitParenthesis ? $expression : "($expression)";

return "<?php echo app('arrilot.widget')->run{$expression}; ?>";
});

Blade::directive('asyncWidget', function ($expression) {
return "<?php echo app('arrilot.async-widget')->run({$expression}); ?>";
Blade::directive('asyncWidget', function ($expression) use ($omitParenthesis) {
$expression = $omitParenthesis ? $expression : "($expression)";

return "<?php echo app('arrilot.async-widget')->run{$expression}; ?>";
});

Blade::directive('widgetGroup', function ($expression) {
return "<?php echo app('arrilot.widget-group-collection')->group({$expression})->display(); ?>";
Blade::directive('widgetGroup', function ($expression) use ($omitParenthesis) {
$expression = $omitParenthesis ? $expression : "($expression)";

return "<?php echo app('arrilot.widget-group-collection')->group{$expression}->display(); ?>";
});
}

Expand Down

0 comments on commit 336f456

Please sign in to comment.