3 namespace BookStack\Providers;
6 use BookStack\Auth\Access\SocialAuthService;
7 use BookStack\Entities\BreadcrumbsViewComposer;
8 use BookStack\Entities\Models\Book;
9 use BookStack\Entities\Models\Bookshelf;
10 use BookStack\Entities\Models\Chapter;
11 use BookStack\Entities\Models\Page;
12 use BookStack\Settings\Setting;
13 use BookStack\Settings\SettingService;
14 use Illuminate\Contracts\Cache\Repository;
15 use Illuminate\Database\Eloquent\Relations\Relation;
16 use Illuminate\Support\Facades\View;
17 use Illuminate\Support\ServiceProvider;
18 use Laravel\Socialite\Contracts\Factory as SocialiteFactory;
22 class AppServiceProvider extends ServiceProvider
25 * Bootstrap any application services.
29 public function boot()
32 $appUrl = config('app.url');
34 $isHttps = (strpos($appUrl, 'https://') === 0);
35 URL::forceRootUrl($appUrl);
36 URL::forceScheme($isHttps ? 'https' : 'http');
39 // Custom blade view directives
40 Blade::directive('icon', function ($expression) {
41 return "<?php echo icon($expression); ?>";
44 // Allow longer string lengths after upgrade to utf8mb4
45 Schema::defaultStringLength(191);
47 // Set morph-map due to namespace changes
49 'BookStack\\Bookshelf' => Bookshelf::class,
50 'BookStack\\Book' => Book::class,
51 'BookStack\\Chapter' => Chapter::class,
52 'BookStack\\Page' => Page::class,
56 View::composer('partials.breadcrumbs', BreadcrumbsViewComposer::class);
60 * Register any application services.
64 public function register()
66 $this->app->singleton(SettingService::class, function ($app) {
67 return new SettingService($app->make(Setting::class), $app->make(Repository::class));
70 $this->app->singleton(SocialAuthService::class, function ($app) {
71 return new SocialAuthService($app->make(SocialiteFactory::class));