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\Http\UploadedFile;
12 use Illuminate\Support\ServiceProvider;
16 class AppServiceProvider extends ServiceProvider
19 * Bootstrap any application services.
23 public function boot()
25 // Custom validation methods
26 Validator::extend('image_extension', function ($attribute, $value, $parameters, $validator) {
27 $validImageExtensions = ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'tiff', 'webp'];
28 return in_array(strtolower($value->getClientOriginalExtension()), $validImageExtensions);
32 // Custom blade view directives
33 Blade::directive('icon', function ($expression) {
34 return "<?php echo icon($expression); ?>";
37 // Allow longer string lengths after upgrade to utf8mb4
38 Schema::defaultStringLength(191);
40 // Set morph-map due to namespace changes
42 'BookStack\\Bookshelf' => Bookshelf::class,
43 'BookStack\\Book' => Book::class,
44 'BookStack\\Chapter' => Chapter::class,
45 'BookStack\\Page' => Page::class,
50 * Register any application services.
54 public function register()
56 $this->app->singleton(SettingService::class, function ($app) {
57 return new SettingService($app->make(Setting::class), $app->make('Illuminate\Contracts\Cache\Repository'));