I am working with Laravel and in the controller I am using a middleware function inside constructor as following
class BaseController extends Controller
{
//
public function __construct(){
$this->middleware(function ($request, $next) {
$selected_country_id = session()->get('browse_country_id')??4;
return $next($request);
});
// end of middleware function
//back to constructor function
// How i can use selected_country_id here for example
dd($selected_country_id);
}
}
my question is how to use the variable $selected_country_id outside the middleware function