I have been building a web application that tracks statistics.
These statistics can range between different companies.
I decided to use a main database to house all of the login credentials and each company gets a separate database to themselves.
After the user logins in they will be redirected to this function...
/**
* Redirects the user to the appropriate sub link
*/
public function redirect()
{
Config::set('database.connections.club.database', Auth::user()->club->db_name);
if (Auth::user()->person->role_id == 4) {
return Redirect::to('employee/club_manager/home');
}
}
This function sets the secondary database configuration called club's database equal to the user's associated club.
However when I try to access this configuration later on...
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed`enter code here`
*/
public function handle($request, Closure $next)
{
dd(Config::get('database.connections.club.database'));
if (Auth::user()->role->id == 4)
return $next($request);
}
The dd() will return '', which is the default setting I set in the database.php file.
My question is, how can I save a configuration setting across requests as it appears that Config::set is only saving the setting for a single request.