Letting user access webpage if he has a certain role

Viewed 23

I am making a small webpage with Laravel that has User and Admin roles. My 'users' table consists of name, email, password and role value (0 for user, 1 for admin).

I dont need anything fancy so can I just make it so every time a normal user loads in a page that's meant for the administrator - he gets redirected?

To be more precise: How can I make it so whenever a new page loads, the users role gets checked and then my if or can statement checks if the users allowed to access the page?

For example I have a view: results that displays all the match results(can be accessed by everyone) and I also have an admin/RESULTSadmin view, that should only be accessed by a user that has an admin role but the rest needs to get redirected. Thank you in advance!

1 Answers
Related