1 <?php namespace BookStack\Providers;
4 use BookStack\Entities\Book;
5 use BookStack\Entities\Bookshelf;
6 use BookStack\Entities\Chapter;
7 use BookStack\Entities\Page;
8 use BookStack\Settings\Setting;
9 use BookStack\Settings\SettingService;
10 use Illuminate\Database\Eloquent\Relations\Relation;
11 use Illuminate\Support\ServiceProvider;
15 class AppServiceProvider extends ServiceProvider
18 * Bootstrap any application services.
22 public function boot()
24 // Custom validation methods
25 Validator::extend('is_image', function ($attribute, $value, $parameters, $validator) {
26 $imageMimes = ['image/png', 'image/bmp', 'image/gif', 'image/jpeg', 'image/jpg', 'image/tiff', 'image/webp'];
27 return in_array($value->getMimeType(), $imageMimes);
30 // Custom blade view directives
31 Blade::directive('icon', function ($expression) {
32 return "<?php echo icon($expression); ?>";
35 // Allow longer string lengths after upgrade to utf8mb4
36 Schema::defaultStringLength(191);
38 // Set morph-map due to namespace changes
40 'BookStack\\Bookshelf' => Bookshelf::class,
41 'BookStack\\Book' => Book::class,
42 'BookStack\\Chapter' => Chapter::class,
43 'BookStack\\Page' => Page::class,
48 * Register any application services.
52 public function register()
54 $this->app->singleton(SettingService::class, function ($app) {
55 return new SettingService($app->make(Setting::class), $app->make('Illuminate\Contracts\Cache\Repository'));