Route (eg. /home) shared by multiple roles. Your solution? Route (eg. /home) shared by multiple roles. Your solution?
I simply namespace:
/home For the most common user
/teachers/home for teacher role
So on. Some people reuse /home but do role checks in the controller which I think is fugly.
So alternatives or solutions you may have?
Use blade directive includeWhen.
So you’re pushing the conditional to the view. That’s interesting in general, could be useful in some cases.
But having conditionals in the view rather than controller seems to be just shifting the problem. You still end up with conditionals all over.
I’ve actually been thinking it could be handled via middleware. Wondering if anyone has that approach.
So you’re pushing the conditional to the view.
That is just a suggestion for you. I do not use that. My code is written in a way that there are no conditionals within controllers or blade files.
I avoid conditionals as well. :)
To me namespacing the route is perfectly fine. But some people/projects are OCD about this stuff. So looking for ideas on how else to architect this.
I encapsulate that logic in an appropriate place/class and use lookup/strategy-pattern. No cleaner/easier way than that.
@uhoh Simple: I don’t have “home” pages for each role and just have a user dashboard. That dashboard then displays whatever content is relevant to that user’s role.
Hi Bug,
code sample / example per chance? thanks
@bugsysha
Give an example from your system what date you have and to what values you want it to correspond.
Please sign in or create an account to participate in this conversation.