Skip to content

Instantly share code, notes, and snippets.

@deleugpn
Last active October 28, 2017 19:52
Show Gist options
  • Save deleugpn/63402898dbb871f65605fa14e5149b71 to your computer and use it in GitHub Desktop.
Save deleugpn/63402898dbb871f65605fa14e5149b71 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class Tenant
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$user = Auth::user();
if (! is_null($user)) {
$user->company->connect();
}
return $next($request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment