make static analyz for blogPost

This commit is contained in:
2024-01-10 14:42:34 +03:00
parent 93ca684f67
commit fb3670a549
14 changed files with 120 additions and 69 deletions

View File

@@ -4,6 +4,8 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Builder;
/**
* App\Models\BlogPostCommentUpvote
@@ -36,28 +38,32 @@ class BlogPostCommentUpvote extends Model
{
use HasFactory;
/**
* @var array<string>
*/
protected $fillable = [
'user_id',
'blog_post_comment_id',
'type',
];
public function author()
public function author(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}
public function blog_post_comment()
public function blog_post_comment(): BelongsTo
{
return $this->belongsTo(BlogPostComment::class, 'blog_post_comment_id');
}
public function scopeForBlogPostCommentsUpVote($query, BlogPostComment $comment)
public function scopeForBlogPostCommentsUpVote(Builder $query, BlogPostComment $comment): Builder
{
return $query->where('blog_post_comment_id', $comment->id)->where('type', 'upvote');
}
public function scopeForBlogPostCommentsDownVote($query, BlogPostComment $comment)
public function scopeForBlogPostCommentsDownVote(Builder $query, BlogPostComment $comment): Builder
{
return $query->where('blog_post_comment_id', $comment->id)->where('type', 'downvote');
}