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