1 <?php namespace BookStack\Providers;
4 use BookStack\Entities\Models\Book;
5 use BookStack\Entities\Models\Bookshelf;
6 use BookStack\Entities\BreadcrumbsViewComposer;
7 use BookStack\Entities\Models\Chapter;
8 use BookStack\Entities\Models\Page;
9 use BookStack\Settings\Setting;
10 use BookStack\Settings\SettingService;
11 use Illuminate\Database\Eloquent\Relations\Relation;
12 use Illuminate\Support\Facades\View;
13 use Illuminate\Support\ServiceProvider;
17 class AppServiceProvider extends ServiceProvider
20 * Bootstrap any application services.
24 public function boot()
27 $appUrl = config('app.url');
29 $isHttps = (strpos($appUrl, 'https://') === 0);
30 URL::forceRootUrl($appUrl);
31 URL::forceScheme($isHttps ? 'https' : 'http');
34 // Custom blade view directives
35 Blade::directive('icon', function ($expression) {
36 return "<?php echo icon($expression); ?>";
39 // Allow longer string lengths after upgrade to utf8mb4
40 Schema::defaultStringLength(191);
42 // Set morph-map due to namespace changes
44 'BookStack\\Bookshelf' => Bookshelf::class,
45 'BookStack\\Book' => Book::class,
46 'BookStack\\Chapter' => Chapter::class,
47 'BookStack\\Page' => Page::class,
51 View::composer('partials.breadcrumbs', BreadcrumbsViewComposer::class);
55 * Register any application services.
59 public function register()
61 $this->app->singleton(SettingService::class, function ($app) {
62 return new SettingService($app->make(Setting::class), $app->make('Illuminate\Contracts\Cache\Repository'));