$upvotes * @property-read int|null $upvotes_count * * @method static \Illuminate\Database\Eloquent\Builder|DietComment newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|DietComment newQuery() * @method static \Illuminate\Database\Eloquent\Builder|DietComment query() * @method static \Illuminate\Database\Eloquent\Builder|DietComment whereBody($value) * @method static \Illuminate\Database\Eloquent\Builder|DietComment whereCreatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|DietComment whereDietId($value) * @method static \Illuminate\Database\Eloquent\Builder|DietComment whereGrade($value) * @method static \Illuminate\Database\Eloquent\Builder|DietComment whereId($value) * @method static \Illuminate\Database\Eloquent\Builder|DietComment whereUpdatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|DietComment whereUserId($value) * * @mixin \Eloquent */ class DietComment extends Model { use HasFactory; public function author(): BelongsTo { return $this->belongsTo(User::class, 'user_id'); } public function diet(): BelongsTo { return $this->belongsTo(Diet::class, 'diet_id'); } public function upvotes(): HasMany { return $this->hasMany(DietCommentUpvote::class, 'comment_id'); } public function isUpVoted(): bool|int { if (auth()->user()) { return auth() ->user() ->diet_comment_upvotes() ->forDietCommentsUpVote($this) ->count(); } return false; } public function isDownVoted(): bool|int { if (auth()->user()) { return auth() ->user() ->diet_comment_upvotes() ->forDietCommentsDownVote($this) ->count(); } return false; } public function removeUpVote(): bool|int { if (auth()->user()) { return auth() ->user() ->diet_comment_upvotes() ->forDietCommentsUpVote($this) ->delete(); } return false; } public function removeDownVote(): bool { if (auth()->user()) { return auth() ->user() ->diet_comment_upvotes() ->forDietCommentsDownVote($this) ->delete(); } return false; } }