love_php/app/Models/Live/Anchor.php

67 lines
1.7 KiB
PHP
Raw Permalink Normal View History

2026-04-02 09:20:51 +08:00
<?php
namespace App\Models\Live;
use App\Models\Course\Course;
use Illuminate\Database\Eloquent\Model;
use App\Models\User;
use App\Models\MerchantAccount;
use Illuminate\Database\Eloquent\SoftDeletes;
class Anchor extends Model
{
use SoftDeletes;
protected $fillable = ['m_id'];
protected $table = 'live_anchors';
public function viewer(){
return $this->belongsTo(Viewer::class, 'viewer_id');
}
public function viewerV2(){
return $this->belongsTo(Viewer::class, 'mobile','mobile');
}
public function viewerV3(){
return $this->belongsTo(Viewer::class, 'openid','openid');
}
public function focu(){
return $this->hasOne(AnchorViewer::class, 'anchor_id');
}
public function reward(){
return $this->hasMany(GiftOrder::class, 'teacher_id');
}
public function live(){
return $this->hasMany(Live::class, 'anchor_id');
}
public function operator(){
return $this->belongsTo(User::class,'follow_user')->select('id','nickname','circle_avatar','app_avatar','sex','mobile');
}
/** 关联商户 */
public function merchant(){
return $this->belongsTo(MerchantAccount::class, 'mobile', 'mobile');
}
public function merchantv2(){
return $this->belongsTo(MerchantAccount::class, 'm_id', 'id');
}
/** 关联文章 */
public function articles(){
return $this->hasMany(\App\Models\AnchorArticle::class);
}
/** 关联视频 */
public function videos(){
return $this->hasMany(\App\Models\AnchorVideo::class);
}
/** 关联课程 */
public function course(){
return $this->hasMany(Course::class,'merchant_id','m_id')->where('is_show',1);
}
}