I want to filter replies based on query parameter passed, query parameters can be post_id, comment_id and array of reply_ids all can be optional and can be used as combination
$query = Post::where('user_id', auth()->id());
if ( isset($data['reply_ids']) ) {
$query = $query->with('posts.comments.replies')->whereHas('posts.comments.replies', function($query) use ($data){
$query->whereIn('id', $data['reply_ids']);
});
}
Now, if I want to filter again with comment authors
, that is on comments table, if I want to add filters of post author
, that will be on posts table, how I can add those conditional, and still that will be optional?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire