loadViewsFrom(__DIR__ . '/../../resources/views', 'survey'); // Load translation $this->loadTranslationsFrom(__DIR__ . '/../../resources/lang', 'survey'); // Load migrations $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations'); // Call pblish redources function $this->publishResources(); } /** * Register the service provider. * * @return void */ public function register() { $this->mergeConfig(); $this->registerSurvey(); $this->registerFacade(); $this->registerBindings(); //$this->registerCommands(); } /** * Register the application bindings. * * @return void */ protected function registerSurvey() { $this->app->bind('survey', function($app) { return new Survey($app); }); } /** * Register the vault facade without the user having to add it to the app.php file. * * @return void */ public function registerFacade() { $this->app->booting(function() { $loader = \Illuminate\Foundation\AliasLoader::getInstance(); $loader->alias('Survey', 'Lavalite\Survey\Facades\Survey'); }); } /** * Register bindings for the provider. * * @return void */ public function registerBindings() { // Bind facade $this->app->bind('survey.survey', function ($app) { return $this->app->make('Survey\Survey\Survey'); }); // Bind Survey to repository $this->app->bind( 'Survey\Survey\Interfaces\SurveyRepositoryInterface', \Survey\Survey\Repositories\Eloquent\SurveyRepository::class ); // Bind Audience to repository $this->app->bind( 'Survey\Survey\Interfaces\AudienceRepositoryInterface', \Survey\Survey\Repositories\Eloquent\AudienceRepository::class ); // Bind Distribution to repository $this->app->bind( 'Survey\Survey\Interfaces\DistributionRepositoryInterface', \Survey\Survey\Repositories\Eloquent\DistributionRepository::class ); // Bind Reminder to repository $this->app->bind( 'Survey\Survey\Interfaces\ReminderRepositoryInterface', \Survey\Survey\Repositories\Eloquent\ReminderRepository::class ); // Bind Reporting to repository $this->app->bind( 'Survey\Survey\Interfaces\ReportingRepositoryInterface', \Survey\Survey\Repositories\Eloquent\ReportingRepository::class ); // Bind Theme to repository $this->app->bind( 'Survey\Survey\Interfaces\ThemeRepositoryInterface', \Survey\Survey\Repositories\Eloquent\ThemeRepository::class ); // Bind Notific to repository $this->app->bind( 'Survey\Survey\Interfaces\NotificRepositoryInterface', \Survey\Survey\Repositories\Eloquent\NotificRepository::class ); $this->app->register(\Survey\Survey\Providers\AuthServiceProvider::class); $this->app->register(\Survey\Survey\Providers\RouteServiceProvider::class); } /** * Merges user's and survey's configs. * * @return void */ protected function mergeConfig() { $this->mergeConfigFrom( __DIR__ . '/../../config/config.php', 'survey.survey' ); } /** * Register scaffolding command */ protected function registerCommands() { if ($this->app->runningInConsole()) { $this->commands([ Commands\MakeSurvey::class, ]); } } /** * Get the services provided by the provider. * * @return array */ public function provides() { return ['survey.survey']; } /** * Publish resources. * * @return void */ private function publishResources() { // Publish configuration file $this->publishes([__DIR__ . '/../../config/config.php' => config_path('survey/survey.php')], 'config'); // Publish admin view $this->publishes([__DIR__ . '/../../resources/views' => base_path('resources/views/vendor/survey')], 'view'); // Publish language files $this->publishes([__DIR__ . '/../../resources/lang' => base_path('resources/lang/vendor/survey')], 'lang'); // Publish public files and assets. $this->publishes([__DIR__ . '/public/' => public_path('/')], 'public'); } }