71 lines
1.8 KiB
PHP
71 lines
1.8 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use App\Models\Base;
|
||
|
|
use App\Models\Course\Course;
|
||
|
|
|
||
|
|
|
||
|
|
class Order extends Base
|
||
|
|
{
|
||
|
|
protected $fillable = [];
|
||
|
|
protected $guarded = [];
|
||
|
|
|
||
|
|
public function user()
|
||
|
|
{
|
||
|
|
return $this->belongsTo("App\Models\User", 'user_id', 'id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function orderRemarks()
|
||
|
|
{
|
||
|
|
return $this->hasMany(OrderRemarks::class);
|
||
|
|
}
|
||
|
|
public function course()
|
||
|
|
{
|
||
|
|
return $this->hasOne(Course::class,'id','type_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function payorder()
|
||
|
|
{
|
||
|
|
return $this->hasOne(PayOrder::class, 'trade_no', 'trade_no');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function fromOpenidUser()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(Wechat::class,'from_openid', 'openid');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function fromUserIdUser()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(User::class,'from_user_id', 'id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function clientComments(){
|
||
|
|
return $this->belongsTo(ClientComment::class,'user_id', 'user_id')->orderBy('created_at','desc');
|
||
|
|
}
|
||
|
|
//取最新一条备注
|
||
|
|
public function clientComment(){
|
||
|
|
return $this->belongsTo(ClientComment::class,'user_id', 'user_id')->orderBy('created_at','desc')->limit(1);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function subRank(){
|
||
|
|
return $this->belongsTo(SubRank::class,'type_id', 'id');
|
||
|
|
}
|
||
|
|
public function singleService(){
|
||
|
|
return $this->belongsTo(SingleService::class,'type_id', 'id');
|
||
|
|
}
|
||
|
|
public function activity(){
|
||
|
|
return $this->belongsTo(Activity::class,'type_id', 'id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function earning(){
|
||
|
|
return $this->hasMany(Earning::class,'order_id','id')->whereIn('sharer', ['first_sharer', 'other_sharer', 'last_sharer', 'merchant']);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function refundOrders()
|
||
|
|
{
|
||
|
|
return $this->hasMany(RefundOrder::class, 'trade_no', 'trade_no');
|
||
|
|
}
|
||
|
|
}
|