The laravel application url will be something like app.laravel.com\{clientName}. All the routes will be following the client_name, for example app.laravel.com\{clientName}\home, app.laravel.com\{clientName}\profile. Will load/ render the application depends on the clientName.
routes/web.php
Route::group(['prefix' => '{clientName}', 'middleware' => 'appclient'], function () {
Route::get('/', 'ClientController@index');
Route::post('login', 'Auth\LoginController@login');
Route::post('logout', 'Auth\LoginController@logout');
Route::get('home', 'HomeController@index');
});
In the appclient middleware
public function handle($request, Closure $next) {
$clientName = explode('/', $request->path())[0];
$client = Client::where('clientName', $clientName)->first();
if(!isset($client->id)) {
abort(404);
}
Config::set('session.path', "/$clientName");
return $next($request);
}
What I'm trying to achieve is set the session based on the clientName directory. When I login keep redirecting to main page, the session is not working.
How can I fixed this issue? Is it a good idea to updating the session path in the middleware?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire