2016-09-03 07:08:58 -04:00
|
|
|
<?php namespace BookStack\Providers;
|
2015-07-12 15:01:42 -04:00
|
|
|
|
2017-02-05 13:57:57 -05:00
|
|
|
use BookStack\Services\SettingService;
|
|
|
|
use BookStack\Setting;
|
2015-07-12 15:01:42 -04:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2016-12-31 09:38:04 -05:00
|
|
|
use Validator;
|
2015-07-12 15:01:42 -04:00
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
2016-07-01 15:11:49 -04:00
|
|
|
// Custom validation methods
|
2018-03-24 11:25:13 -04:00
|
|
|
Validator::extend('is_image', function ($attribute, $value, $parameters, $validator) {
|
2016-07-01 15:11:49 -04:00
|
|
|
$imageMimes = ['image/png', 'image/bmp', 'image/gif', 'image/jpeg', 'image/jpg', 'image/tiff', 'image/webp'];
|
|
|
|
return in_array($value->getMimeType(), $imageMimes);
|
|
|
|
});
|
2017-02-04 06:01:49 -05:00
|
|
|
|
2018-01-28 11:58:52 -05:00
|
|
|
\Blade::directive('icon', function ($expression) {
|
2017-02-04 06:01:49 -05:00
|
|
|
return "<?php echo icon($expression); ?>";
|
|
|
|
});
|
2017-07-02 12:20:05 -04:00
|
|
|
|
|
|
|
// Allow longer string lengths after upgrade to utf8mb4
|
|
|
|
\Schema::defaultStringLength(191);
|
2015-07-12 15:01:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
2018-01-28 11:58:52 -05:00
|
|
|
$this->app->singleton(SettingService::class, function ($app) {
|
2017-02-05 13:57:57 -05:00
|
|
|
return new SettingService($app->make(Setting::class), $app->make('Illuminate\Contracts\Cache\Repository'));
|
|
|
|
});
|
2015-07-12 15:01:42 -04:00
|
|
|
}
|
|
|
|
}
|