12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace Encore\Admin\Middleware;
- use Encore\Admin\Admin;
- use Encore\Admin\Form;
- use Encore\Admin\Grid;
- use Illuminate\Http\Request;
- class Bootstrap
- {
- public function handle(Request $request, \Closure $next)
- {
- Form::registerBuiltinFields();
- Grid::registerColumnDisplayer();
- if (file_exists($bootstrap = admin_path('bootstrap.php'))) {
- require $bootstrap;
- }
- if (!empty(Admin::$booting)) {
- foreach (Admin::$booting as $callable) {
- call_user_func($callable);
- }
- }
- $this->injectFormAssets();
- if (!empty(Admin::$booted)) {
- foreach (Admin::$booted as $callable) {
- call_user_func($callable);
- }
- }
- return $next($request);
- }
- /**
- * Inject assets of all form fields.
- */
- protected function injectFormAssets()
- {
- $assets = Form::collectFieldAssets();
- Admin::css($assets['css']);
- Admin::js($assets['js']);
- }
- }
|