@reviewdevs You can use both, like:
public function index(User $currentUser)
{
if ($currentUser->hasRole('premium');) {
return true;
}
return false;
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, am trying to make something like Udemy as practice after finishing some courses here on Laracasts
I'm trying to fix a problem where I want to allow users who purchased a course to view it, if not, they get 401
I was thinking of two approaches, either using Policies combined with Roles and permissions
like saying
if user can view any course, then respond to him with the courses videos
else, check if user has this course in his purchased courses, then send him the course videos
else, unauthorized
that was the the Policies + roles & permissions approach
but i read that u can do so with Middlewares and it seemed easier to do it with middlewares from this article
https://justlaravel.com/middleware-laravel-content-restriction-user-role/
so i was wondering if someone could explain to me which is better and more scalable in the future
thanks a lot!
Please or to participate in this conversation.