forked from eatvio/eatvio-infra
70 lines
2.6 KiB
PHP
70 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* App\Models\BlogPostCommentUpvote
|
|
*
|
|
* @property int $id
|
|
* @property int $blog_post_comment_id
|
|
* @property int $user_id
|
|
* @property string $type
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
*
|
|
* @property-read \App\Models\User|null $author
|
|
* @property-read \App\Models\BlogPostComment|null $blog_post_comment
|
|
*
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BlogPostCommentUpvote forBlogPostCommentsDownVote(\App\Models\BlogPostComment $comment)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BlogPostCommentUpvote forBlogPostCommentsUpVote(\App\Models\BlogPostComment $comment)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BlogPostCommentUpvote newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BlogPostCommentUpvote newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BlogPostCommentUpvote query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BlogPostCommentUpvote whereBlogPostCommentId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BlogPostCommentUpvote whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BlogPostCommentUpvote whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BlogPostCommentUpvote whereType($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BlogPostCommentUpvote whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BlogPostCommentUpvote whereUserId($value)
|
|
*
|
|
* @mixin \Eloquent
|
|
*/
|
|
class BlogPostCommentUpvote extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* @var array<string>
|
|
*/
|
|
protected $fillable = [
|
|
'user_id',
|
|
'blog_post_comment_id',
|
|
'type',
|
|
];
|
|
|
|
public function author(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'user_id');
|
|
}
|
|
|
|
public function blog_post_comment(): BelongsTo
|
|
{
|
|
return $this->belongsTo(BlogPostComment::class, 'blog_post_comment_id');
|
|
}
|
|
|
|
public function scopeForBlogPostCommentsUpVote(Builder $query, BlogPostComment $comment): Builder
|
|
{
|
|
return $query->where('blog_post_comment_id', $comment->id)->where('type', 'upvote');
|
|
}
|
|
|
|
public function scopeForBlogPostCommentsDownVote(Builder $query, BlogPostComment $comment): Builder
|
|
{
|
|
return $query->where('blog_post_comment_id', $comment->id)->where('type', 'downvote');
|
|
}
|
|
}
|