Laravel - Using scope

99封情书 提交于 2020-03-25 18:47:27

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!