1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- class Ordertest extends Model{
- protected $table='order_all';
- protected $guarded=[];
- public function order_detail(){
- return $this->hasMany(OrderDetail::class,'order_id');
- }
- public function order_details(){
- return $this->hasManyThrough(Goodtest::class,OrderDetail::class,'order_id','id','id','goods_id');
- }
- public function get_gift_infos(){
- return $this->belongsToMany(Gift::class,OrderGift::class,'order_id','gift_id')->withPivot('num');
- }
- public function get_user(){
- return $this->belongsTo(User::class,'user_id');
- }
- public function get_gift(){
- return $this->hasMany(OrderGift::class,'order_id','id');
- }
- public function get_log(){
- return $this->hasMany(Orderlog::class,'order_id','id');
- }
- public function address(){
- return $this->belongsTo(Address::class,'address_id');
- }
- public function get_address(){
- return $this->belongsToMany(User::class,Address::class,'id','mobile','address_id','mobile')->whereIn('cert_status',[3,6]);
- }
- /**获取物流信息**/
- public function get_express(){
- return $this->hasMany(Express::class,'order_id');
- }
- public function belong_user(){
- return $this->belongsTo(User::class,'good_user_id');
- }
- }
|