$upvotes * @property-read int|null $upvotes_count * * @method static \Illuminate\Database\Eloquent\Builder|BlogPostComment newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|BlogPostComment newQuery() * @method static \Illuminate\Database\Eloquent\Builder|BlogPostComment query() * @method static \Illuminate\Database\Eloquent\Builder|BlogPostComment whereBlogPostId($value) * @method static \Illuminate\Database\Eloquent\Builder|BlogPostComment whereBody($value) * @method static \Illuminate\Database\Eloquent\Builder|BlogPostComment whereCreatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|BlogPostComment whereGrade($value) * @method static \Illuminate\Database\Eloquent\Builder|BlogPostComment whereId($value) * @method static \Illuminate\Database\Eloquent\Builder|BlogPostComment whereUpdatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|BlogPostComment whereUserId($value) * * @mixin \Eloquent */ class BlogPostComment extends Model { use HasFactory; public function author() { return $this->belongsTo(User::class, 'user_id'); } public function blog_post() { return $this->belongsTo(BlogPost::class, 'blog_post_id'); } public function upvotes(): HasMany { return $this->hasMany(BlogPostCommentUpvote::class, 'blog_post_comment_id'); } public function isUpVoted(): bool { $curUser = auth()->user(); if ($curUser) { return $curUser ->blog_post_comment_upvotes() ->forBlogPostCommentsUpVote($this) ->count(); } return false; } public function isDownVoted(): bool { $curUser = auth()->user(); if ($curUser) { return $curUser ->blog_post_comment_upvotes() ->forBlogPostCommentsDownVote($this) ->count(); } return false; } public function removeUpVote(): bool { $curUser = auth()->user(); if ($curUser) { return $curUser ->blog_post_comment_upvotes() ->forBlogPostCommentsUpVote($this) ->delete(); } return false; } public function removeDownVote(): bool { $curUser = auth()->user(); if ($curUser) { return $curUser ->blog_post_comment_upvotes() ->forBlogPostCommentsDownVote($this) ->delete(); } return false; } }