forked from eatvio/eatvio-infra
same at 22.05.2023
This commit is contained in:
38
app/Models/BlogPostCommentUpvote.php
Normal file
38
app/Models/BlogPostCommentUpvote.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BlogPostCommentUpvote extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'blog_post_comment_id',
|
||||
'type'
|
||||
];
|
||||
|
||||
public function author()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function blog_post_comment()
|
||||
{
|
||||
return $this->belongsTo(BlogPostComment::class, 'blog_post_comment_id');
|
||||
}
|
||||
|
||||
public function scopeForBlogPostCommentsUpVote($query, BlogPostComment $comment)
|
||||
{
|
||||
return $query->where('blog_post_comment_id', $comment->id)->where('type', 'upvote');
|
||||
}
|
||||
|
||||
public function scopeForBlogPostCommentsDownVote($query, BlogPostComment $comment)
|
||||
{
|
||||
return $query->where('blog_post_comment_id', $comment->id)->where('type', 'downvote');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user