belongsTo(User::class, 'user_id'); } public function diet_comment(): BelongsTo { return $this->belongsTo(DietComment::class, 'comment_id'); } public function scopeForDietCommentsUpVote(Builder $query, DietComment $comment): Builder { return $query->where('comment_id', $comment->id)->where('type', 'upvote'); } public function scopeForDietCommentsDownVote(Builder $query, DietComment $comment): Builder { return $query->where('comment_id', $comment->id)->where('type', 'downvote'); } }