mergeConfigFrom( __DIR__.'/config/config.php', 'laravel-widgets' ); $this->app->bind('arrilot.widget', function () { return new WidgetFactory(new LaravelApplicationWrapper()); }); $this->app->bind('arrilot.async-widget', function () { return new AsyncWidgetFactory(new LaravelApplicationWrapper()); }); $this->app->singleton('arrilot.widget-group-collection', function () { return new WidgetGroupCollection(new LaravelApplicationWrapper()); }); $this->app->singleton('arrilot.widget-namespaces', function () { return new NamespacesRepository(); }); $this->app->singleton('command.widget.make', function ($app) { return new WidgetMakeCommand($app['files']); }); $this->commands('command.widget.make'); $this->app->alias('arrilot.widget', 'Arrilot\Widgets\Factories\WidgetFactory'); $this->app->alias('arrilot.async-widget', 'Arrilot\Widgets\Factories\AsyncWidgetFactory'); $this->app->alias('arrilot.widget-group-collection', 'Arrilot\Widgets\WidgetGroupCollection'); } /** * Bootstrap the application events. * * @return void */ public function boot() { $this->publishes([ __DIR__.'/config/config.php' => config_path('laravel-widgets.php'), ]); $routeConfig = [ 'namespace' => 'Arrilot\Widgets\Controllers', 'prefix' => 'arrilot', 'middleware' => $this->app['config']->get('laravel-widgets.route_middleware', []), ]; if (!$this->app->routesAreCached()) { $this->app['router']->group($routeConfig, function ($router) { $router->get('load-widget', 'WidgetController@showWidget'); }); } Blade::directive('widget', function ($expression) { return "run($expression); ?>"; }); Blade::directive('asyncWidget', function ($expression) { return "run($expression); ?>"; }); Blade::directive('widgetGroup', function ($expression) { return "group($expression)->display(); ?>"; }); } /** * Get the services provided by the provider. * * @return array */ public function provides() { return ['arrilot.widget', 'arrilot.async-widget']; } }