laravel middleware in constructor
public function __construct(User $user)
{
$this->user = $user;
$this->middleware(function ($request, $next) {
$user = auth()->user();
if ($user) {
$this->user = $user;
}
return $next($request);
});
}