forked from eatvio/eatvio-infra
38 lines
889 B
PHP
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');
|
|
}
|
|
}
|