public function scopeWithReplies($query, $withReplies) { switch ($withReplies) { case 'only': $query->where('topic_replies_real', '<>', 0); break; case 'none': $query->where('topic_replies_real', 0); break; } }