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

50 lines
1.2 KiB
PHP

<?php
namespace App\Models\Live;
use App\Models\CommunityStar;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Task extends Model
{
use SoftDeletes;
protected $table = 'live_task';
public function live(){
return $this->belongsTo(Live::class);
}
//通过这个任务进来申请的使者
public function messenger(){
return $this->hasMany(Messenger::class);
}
//通过这个任务注册的用户
public function viewer(){
return $this->hasMany(Viewer::class);
}
//通过这个任务注册的征婚
public function star(){
return $this->hasMany(CommunityStar::class);
}
//完成任务的用户
public function finisher(){
return $this->belongsToMany(Viewer::class, 'task_viewer')
->withPivot('task_id', 'viewer_id', 'other_viewer_id', 'created_at', 'updated_at')
->orderBy('task_viewer.created_at', 'desc')
->withTimestamps();
}
public function taskViewer(){
return $this->hasMany(taskViewer::class);
}
public function viewerShareAudit(){
return $this->hasMany(ViewerShareAudit::calss, 'task_id');
}
}