问题
I am using scope to specify if i am not an admin, then return courses only by instructor. What I am trying to do is when an instructor signs into their account they can only view the course they have been assigned to teach.. I am unsure where i have gone wrong in my query.. it is throwing no errors so i know it has not broke it.. which is a good thing? But my query is not displaying the results I need. I appreciate any help. Thanks
回答1:
Your instructor relation doesn't have user_id because it is in your pivot table.
Try this inner query: $q->where('id', Auth::user()->id);
来源:https://stackoverflow.com/questions/60623026/laravel-using-scope