Free and Paid Resources
I want to restrict navigation resource like below use-case, where free/paid can have options
Use-cases:
1. When any user login, they should see all resources in navigation
2. If not subscribe, auto redirect to free resource when logging in
3. If not subscribe, they can browse free resource. If they click "paid" resource, it should ask "Confirmation" or "redirect to payment page"
3. If subscribed, they can access all
How can I can restrict like this, or is there a plugins which can handle this?
Or any advice on how to implement like this for Advance Navigation, thanks in advance.
For simplicity, imagine this "free/paid" logic will be check by
is_subscribe
boolean column.
Solution:Jump to solution
I tried to quickly create something, and ended up with this: use resources as regular resources, but then add global middleware to redirect to locked page
9 Replies
I think that the "Fillament/Laravel" way to do that could be using Policies. Have you tried "viewAny" method? This method run before any other policy method in order to know if the resource is available to be shown in navigation, access by a direct URL and so on
viewAny hide both navigation and list page (without permission), but what if I put custom url, and display correct navigation... let me try this
Solution
I tried to quickly create something, and ended up with this: use resources as regular resources, but then add global middleware to redirect to locked page


This is AI-generated and I would change a lot but you will probably get the main idea:
and then globally register that middleware in AdminPanelProvider

I will probably shoot a video next week when I tidy up this project, but wanted to give you the idea
Yup. What @PovilasKorop says could be a better way. I'm not sure if you only need to hide the resources or also want to give a "unlock resource" page to your users
No! I really sorry to miss your entire message. I only saw the image, now I notice all the use cases. Sorry for that!
Yes, I will go like this solution.. thank you