-
app/App/Providers/AppServiceProvider.php
Open in GitHubclass AppServiceProvider extends ServiceProvider { // public function register(): void { $this->app->singleton(QueryString::class, function () { $request = $this->app->get(Request::class); return new QueryString(urldecode($request->getRequestUri())); }); $this->app->singleton(Markdown::class, function () { $environment = Environment::createCommonMarkEnvironment(); $convertor = new CommonMarkConverter([], $environment); return new Markdown($convertor); }); $this->app->singleton(Reader::class, fn () => new RssReader()); // $this->app->singleton(LanguageRepository::class, fn () => new LanguageRepository(__DIR__ . '/../../languages.json')); } }
-
app/App/User/Middleware/CurrentUserMiddleware.php
Open in GitHubuse Closure; use Domain\User\Models\User; class CurrentUserMiddleware { public function handle($request, Closure $next) { app()->singleton(User::class, fn () => current_user()); return $next($request); } }