64 lines
2.0 KiB
PHP
64 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Course;
|
|
use App\Models\App\Comment;
|
|
use App\Models\User;
|
|
use App\Models\Course\Course;
|
|
use App\Models\Course\CourseVideo;
|
|
use App\Models\Live\Viewer;
|
|
use App\Models\Server\MerchantUser;
|
|
use Overtrue\LaravelFollow\Traits\CanBeLiked;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CourseComments extends Model
|
|
{
|
|
|
|
use CanBeLiked;
|
|
//评论数
|
|
protected $fillable = [];
|
|
protected $guarded = [];
|
|
public function comments()
|
|
{
|
|
|
|
return $this->hasMany(Comment::class,'commentable_id')->where('commentable_type','App\Models\Course')->orderby('id','desc')->select('id','commentable_id','commented_id','reply_id','comment','created_at');
|
|
}
|
|
public function BusinessComments()
|
|
{
|
|
return $this->hasMany(Comment::class,'commentable_id')->where('commentable_type','App\Models\BesinessCourse')->orderby('id','desc')->select('id','commentable_id','commented_id','reply_id','comment','created_at');
|
|
|
|
}
|
|
//评论数
|
|
public function video()
|
|
{
|
|
|
|
return $this->hasOne(CourseVideo::class,'id','video_id')->select('id','title');
|
|
}
|
|
//用户信息
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class)->select('id','nickname','photo','app_avatar','circle_avatar','circle_avatar as avatar','mobile');
|
|
|
|
}
|
|
//用户信息
|
|
public function course()
|
|
{
|
|
return $this->belongsTo(Course::class,'course_id');
|
|
|
|
}
|
|
//用户信息
|
|
public function member(){
|
|
return $this->belongsTo(Viewer::class,'open_id','openid')->select('openid','avatar','mobile','sex','nickname');
|
|
}
|
|
|
|
//用户信息
|
|
public function s_member(){
|
|
return $this->belongsTo(MerchantUser::class,'open_id','openid')->select('openid','pic as avatar','mobile','sex','nickname','mobile');
|
|
}
|
|
|
|
//用户信息
|
|
public function merchant_user(){
|
|
return $this->belongsTo(MerchantUser::class,'merchant_user_id','id')->select('id','mobile','nickname','pic as avatar');
|
|
}
|
|
}
|