love_php/app/Models/App/Vote.php
2026-04-02 09:20:51 +08:00

41 lines
948 B
PHP

<?php
namespace App\Models\App;
use App\Models\Moment;
use App\Models\User;
use App\Models\App\UserVote;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Overtrue\LaravelFollow\Traits\CanBeLiked;
use Actuallymab\LaravelComment\Contracts\Commentable;
use Actuallymab\LaravelComment\HasComments;
class Vote extends Model implements Commentable
{
use SoftDeletes;
use CanBeLiked;
use HasComments;
protected $guarded = [];
public function option(){
return $this->hasMany(VoteOption::class, 'vote_id');
}
public function parent(){
return $this->belongsTo(Vote::class, 'parent_id');
}
public function user(){
return $this->belongsToMany(User::class);
}
public function moment(){
return $this->hasMany(Moment::class);
}
public function userVote(){
return $this->belongsTo(UserVote::class,'id','vote_id');
}
}