display of the contributions of the logged in user
Hello all,
I wanted to ask how I can make it so that for a given "resource" only the posts created by the logged in user are displayed?
i have already created a policy and defined that users can only edit and see their own posts, however i would like to see only their posts listed, how do i do this?
Solution:Jump to solution
use either:
-
->where('vendor_id', auth()->id())
- ->whereRelation('user', 'vendor_id', auth()->id())
...15 Replies
You need to modify query
can you please explain this in more detail or send me a post about it? sorry, but i'm pretty new to the scene
There's a method getquery something. Use your ide to find it
I have defined this line of code in my product model, and I still do not get the result
push
This is the right way, but you have to review the condition and relation in where()
could you show me an example code?
What is the $model of the resource? and the model relations?
Solution
use either:
-
->where('vendor_id', auth()->id())
- ->whereRelation('user', 'vendor_id', auth()->id())
This doesn't belong on the Model. It belongs on the Resource.
Read what the error message says
You specified the wrong return type