@callumbee Yep that's fine, so if you want to load the categories for a user you would do user()->categories, You can also expand categories with eloquent search methods like user()->where('created_at' > now()->subDay());
Sep 13, 2024
2
Level 6
User related Models
Apologies if this has been asked before and if its a common question. I tried searching about it but struggled to find the right search terms.
I am waiting to get say all the categories for a authorised user. (Auth::user()->categories;) I created a method in the User Model for a belongs to many that returns all the categories for that user and works! But this seems wrong to me as I would expected to get it via the Category Model rather than through the user model. Is the way I have done it correct?
Thanks!
Level 1
1 like
Please or to participate in this conversation.