56 lines
1.5 KiB
PHP
56 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use App\Models\Live\Viewer;
|
||
|
|
use App\Models\Live\Anchor;
|
||
|
|
use App\Models\Consultation;
|
||
|
|
use App\Models\Server\TouristOrder;
|
||
|
|
|
||
|
|
class ConsultationRecords extends Model
|
||
|
|
{
|
||
|
|
//
|
||
|
|
public function viewer(){
|
||
|
|
return $this->hasOne(Viewer::class,'id','viewer_id');
|
||
|
|
}
|
||
|
|
public function anchor(){
|
||
|
|
return $this->hasOne(ConsultAccount::class,'id','anchor_id');
|
||
|
|
}
|
||
|
|
public function fromUser(){
|
||
|
|
return $this->hasOne(Viewer::class,'openid','from_open_id')->select('id','nickname','mobile','avatar','openid');
|
||
|
|
}
|
||
|
|
public function consulation(){
|
||
|
|
return $this->hasOne(Consultation::class,'id','consulation_id');
|
||
|
|
}
|
||
|
|
public function torder(){
|
||
|
|
return $this->belongsTo(TouristOrder::class,'trade_no','trade_no');
|
||
|
|
}
|
||
|
|
public function reservationConsult()
|
||
|
|
{
|
||
|
|
return $this->hasOne(SaasReservationConsultScheduling::class,'id','scheduling_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getCommentTimeAttribute($value)
|
||
|
|
{
|
||
|
|
if (empty($value)){
|
||
|
|
$value = $this->updated_at->toDateTimeString();
|
||
|
|
}
|
||
|
|
return $value;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取已选择预约时间的人数
|
||
|
|
* @param $merchant_id
|
||
|
|
* @param $scheduling_id
|
||
|
|
* @return mixed
|
||
|
|
*/
|
||
|
|
public function getAlreadyReservationNum($merchant_id,$scheduling_id)
|
||
|
|
{
|
||
|
|
return $this->where('scheduling_id',$scheduling_id)
|
||
|
|
->where('merchant_id',$merchant_id)
|
||
|
|
->where('pay_status',1)
|
||
|
|
->count();
|
||
|
|
}
|
||
|
|
}
|