I didn't know how to describe the subject but here's my problem:
I have a model/table named users, and it has a field called type. I made a middleware to give controller access to the specific types. when it passes the middleware, there's no problem. but when the type is not the same, it gives an error like this:
Argument 1 passed to Illuminate\\Routing\\Middleware\\ThrottleRequests::addHeaders() must be an instance of Symfony\\Component\\HttpFoundation\\Response, string given, called in C:\\xampp\\htdocs\\app\\Http\\Middleware\\ThrottleRequests.php on line 3
the thing is, this is giving me a typeError, and it's not the type field I have in my table. I tried to change the field name in case you think this is about my field name.
ps: I didn't do anything else, it's just the default class I didn't try to modify the throttle middleware.
ps: the middlewares I'm using are:
'support' => [
'auth:api',
'customMiddleware',
]
UPDATE:
customeMiddleware:
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$user = Auth::user();
$AccessLevel = 2;
if($user->type >= $AccessLevel){
return $next($request);
}
return "UnAuthorized";
}