forked from eatvio/eatvio-infra
eating plan added
This commit is contained in:
41
app/Models/CommentUpvote.php
Normal file
41
app/Models/CommentUpvote.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\PlanComment;
|
||||
use App\Models\User;
|
||||
|
||||
class CommentUpvote extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'comment_id',
|
||||
'type'
|
||||
];
|
||||
|
||||
public function plan_comment()
|
||||
{
|
||||
return $this->belongsTo(PlanComment::class, 'comment_id');
|
||||
}
|
||||
|
||||
public function author()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function scopeForPlanCommentsUpVote($query, PlanComment $comment)
|
||||
{
|
||||
return $query->where('comment_id', $comment->id)->where('type', 'upvote');
|
||||
}
|
||||
|
||||
public function scopeForPlanCommentsDownVote($query, PlanComment $comment)
|
||||
{
|
||||
return $query->where('comment_id', $comment->id)->where('type', 'downvote');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user