F
Filament14mo ago
Gehts

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?
No description
Solution:
use either: - ->where('vendor_id', auth()->id()) - ->whereRelation('user', 'vendor_id', auth()->id())...
Jump to solution
15 Replies
Gehts
GehtsOP14mo ago
No description
krekas
krekas14mo ago
You need to modify query
Gehts
GehtsOP14mo ago
can you please explain this in more detail or send me a post about it? sorry, but i'm pretty new to the scene
krekas
krekas14mo ago
There's a method getquery something. Use your ide to find it
Gehts
GehtsOP14mo ago
I have defined this line of code in my product model, and I still do not get the result
No description
Gehts
GehtsOP14mo ago
push
MohamedSabil83
MohamedSabil8314mo ago
This is the right way, but you have to review the condition and relation in where()
Gehts
GehtsOP14mo ago
could you show me an example code?
MohamedSabil83
MohamedSabil8314mo ago
What is the $model of the resource? and the model relations?
Gehts
GehtsOP14mo ago
No description
No description
Solution
MohamedSabil83
MohamedSabil8314mo ago
use either: - ->where('vendor_id', auth()->id()) - ->whereRelation('user', 'vendor_id', auth()->id())
Dennis Koch
Dennis Koch14mo ago
This doesn't belong on the Model. It belongs on the Resource.
Gehts
GehtsOP14mo ago
No description
Dennis Koch
Dennis Koch14mo ago
Read what the error message says You specified the wrong return type
Want results from more Discord servers?
Add your server