Recourse list, only show user made entires
Hi,
I have a FreelancerCV resource. I want a freelancer to be able to create their own cv items. On the resource list page, I only want to show the entries made by that freelancer. Every FreelancerCV row in the database has a freelancer_id. How can I edit the query with ->where('freelancer_id', $freelancer_id)?
2 Replies
Modify the query for the resource. Without more info about your model / relationship structure, hard to give you the exact query. But assuming you have a Freelancer model, which itself has a user_id foreign key, and the model you are working on has a freelancer() BelongsTo relationship
Although probably best abstract that whereHas() into a local scope on the Freelancer model, and just apply the scope, as you'll almost certainly need it elsewhere.
thanks this worked