Level 102
Can you show the query you need?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a class that is a comment for a post. they have relationship and it works. Inside POST class:
public function articleComments()
{
return $this->hasMany(ArticleComment::class,'ACM_cdiPost','id')
->orderBy('updated_at','DESC');
}
So far so good. However, I really need more complex query (in sense of not to present muted or blocked users) which is no problem and I use that SQL in another controller. Problem I am facing is how to do this? In class or to make some controller function and call it somehow from blade file?
If the muted or blocked is a flag on the user, you can do something like:
$model->articleComments()->whereDoesntHave('user', function (Builder $query) {
$query->where('muted', 1)->orWhere('blocked', 1);
})->get();
Please or to participate in this conversation.