I created a middleware to check if a user is admin or editor, but for some reason in my if statement when i use the OR operator to check if the user has access, it doesnt work, it accepts the first property statement, but not after the OR operator.
To work i need to separate each condition of account type.
For example:
Code dont work:
public function handle($request, Closure $next)
{
if(Auth::user()->account_type_id == '1' || Auth::user()->account_type_id == '2') // is an admin
{
return $next($request); // pass the admin
}
return redirect('/admin'); // not admin. redirect whereever you like
}
Code that Works:
public function handle($request, Closure $next)
{
// dd($request->all());
if(Auth::user()->account_type_id == '1') // is an admin
{
return $next($request); // pass the admin
}
if(Auth::user()->account_type_id == '2') // is an admin
{
return $next($request); // pass the admin
}
return redirect('/admin'); // not admin. redirect whereever you like
}
Does anybody no whats wrong?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iThw7Y
via IFTTT
Aucun commentaire:
Enregistrer un commentaire