F
Filament16mo 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
GehtsOP16mo ago
No description
krekas
krekas16mo ago
You need to modify query
Gehts
GehtsOP16mo 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
krekas16mo ago
There's a method getquery something. Use your ide to find it
Gehts
GehtsOP16mo ago
I have defined this line of code in my product model, and I still do not get the result
No description
Gehts
GehtsOP16mo ago
push
MohamedSabil83
MohamedSabil8316mo ago
This is the right way, but you have to review the condition and relation in where()
Gehts
GehtsOP16mo ago
could you show me an example code?
MohamedSabil83
MohamedSabil8316mo ago
What is the $model of the resource? and the model relations?
Gehts
GehtsOP16mo ago
No description
No description
Solution
MohamedSabil83
MohamedSabil8316mo ago
use either: - ->where('vendor_id', auth()->id()) - ->whereRelation('user', 'vendor_id', auth()->id())
Dennis Koch
Dennis Koch16mo ago
This doesn't belong on the Model. It belongs on the Resource.
Gehts
GehtsOP16mo ago
No description
Dennis Koch
Dennis Koch16mo ago
Read what the error message says You specified the wrong return type

Did you find this page helpful?