1234567891011121314151617181920212223 |
- <?php
- namespace app\admin\model;
- use think\db\Query;
- use think\Model;
- /**
- * @method Query|static filterAdmin($admin_id)
- */
- class OrderInfo extends \app\common\model\OrderInfo
- {
- public function goods(){
- return $this->belongsTo(Goods::class,'goods_id');
- }
- public function user(){
- return $this->belongsTo(User::class)->setEagerlyType(0);
- }
- public function scopeFilterAdmin(Query $query,$admin_id){
- $query->whereExists(
- Orders::whereRaw("orders.id=order_info.order_id and orders.admin_id=$admin_id")->buildSql()
- );
- }
- }
|