Answer the question
In order to leave comments, you need to log in
Laravel5. How to add an alias for only a certain part of the application?
I have a pseudo separation between backend and frontend, and there is a need to add an alias specifically for the backend.
Previously, I used middle ver to manipulate the configuration:
class Backend
{
public function handle($request, Closure $next)
{
// Namespace для виджетов
Config::set('laravel-widgets.default_namespace', 'App\Widgets\Backend');
// Редирект после успешной аутентификации
Config::set('auth.redirectAfterLogin', 'backend/auth');
return $next($request);
}
}
Config::set('app.aliases', array_merge(Config::get('app.aliases'), [
'AuthHelper' => \App\Helpers\Backend\AuthHelper::class,
]));
или
\App::alias('AuthHelper', \App\Helpers\Backend\AuthHelper::class);
'aliases' => [
...
'AuthHelper' => \App\Helpers\Backend\AuthHelper::class,
...
],
Answer the question
In order to leave comments, you need to log in
Googled:
'
// Перерегистрация класса AuthHelper
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('AuthHelper', \App\Helpers\Backend\AuthHelper::class);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question