| Total Complexity | 3 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class RouteMacros |
||
| 8 | { |
||
| 9 | public function registerMacros() |
||
| 10 | { |
||
| 11 | $this->registerWidget(); |
||
| 12 | |||
| 13 | $this->registerJsonWidget(); |
||
| 14 | } |
||
| 15 | |||
| 16 | private function registerWidget(): void |
||
| 17 | { |
||
| 18 | Route::macro('widget', function ($url, $widget, $name = null) { |
||
| 19 | return Route::get($url, [ |
||
| 20 | 'as' => $name, |
||
| 21 | 'uses' => function (...$args) use ($widget) { |
||
| 22 | return render_widget($widget, $args); |
||
| 23 | }, |
||
| 24 | ]); |
||
| 25 | }); |
||
| 26 | } |
||
| 27 | |||
| 28 | private function registerJsonWidget(): void |
||
| 35 | }, |
||
| 36 | ]); |
||
| 37 | }); |
||
| 40 |