Files
eatvio-infra/app/Models/RecipeCommentUpvote.php
Anatoliy Poloz 92a54106ef analysators added
2023-12-18 14:36:32 +03:00

38 lines
889 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class RecipeCommentUpvote extends Model
{
use HasFactory;
protected $fillable = [
'user_id',
'recipe_comment_id',
'type',
];
public function author()
{
return $this->belongsTo(User::class, 'user_id');
}
public function recipe_comment()
{
return $this->belongsTo(BlogPostComment::class, 'recipe_comment_id');
}
public function scopeForRecipeCommentsUpVote($query, RecipeComment $comment)
{
return $query->where('recipe_comment_id', $comment->id)->where('type', 'upvote');
}
public function scopeForRecipeCommentsDownVote($query, RecipeComment $comment)
{
return $query->where('recipe_comment_id', $comment->id)->where('type', 'downvote');
}
}