* @author Joseph Cohen * @author Graham Campbell */ class AppServiceProvider extends ServiceProvider { /** * Boot the service provider. * * @param \AltThree\Bus\Dispatcher $dispatcher */ public function boot(Dispatcher $dispatcher) { Schema::defaultStringLength(191); $dispatcher->mapUsing(function ($command) { return Dispatcher::simpleMapping($command, 'CachetHQ\Cachet\Bus', 'CachetHQ\Cachet\Bus\Handlers'); }); $dispatcher->pipeThrough([UseDatabaseTransactions::class, ValidatingMiddleware::class]); Str::macro('canonicalize', function ($url) { return preg_replace('/([^\/])$/', '$1/', $url); }); Relation::morphMap([ 'components' => \CachetHQ\Cachet\Models\Component::class, 'incidents' => \CachetHQ\Cachet\Models\Incident::class, 'metrics' => \CachetHQ\Cachet\Models\Metric::class, 'schedules' => \CachetHQ\Cachet\Models\Schedule::class, 'subscriber' => \CachetHQ\Cachet\Models\Subscriber::class, ]); } /** * Register the service provider. * * @return void */ public function register() { $this->registerDateFactory(); } /** * Register the date factory. * * @return void */ protected function registerDateFactory() { $this->app->singleton(DateFactory::class, function ($app) { $appTimezone = $app['config']->get('app.timezone'); $cacheTimezone = $app['config']->get('cachet.timezone'); return new DateFactory($appTimezone, $cacheTimezone); }); } }