Add new db discovery middleware
This commit is contained in:
parent
c25e2e6a6d
commit
e33273e360
2 changed files with 30 additions and 0 deletions
30
app/Http/Middleware/SetWebDb.php
Normal file
30
app/Http/Middleware/SetWebDb.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use Closure;
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
|
||||
class SetWebDb
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (config('ninja.db.multi_db_enabled'))
|
||||
{
|
||||
|
||||
MultiDB::setDB(Cookie::get('db'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue