Current table model
1 / * 2 * categories associated goods management table intermediate the Model . 3 * @auth Jackie <2019.10.18> . 4 * / . 5 public function hasManyGoodsManagementType () . 6 { . 7 return $ the this -> the hasMany (KeyGoodsmanagementType :: class , 'management_id', 'ID' ); . 8 } . 9 10 / * . 11 * @param $ management_type_name goods management category 12 is * @auth Jackie <2019.10.22> 13 is * / 14 public function scopeManagementTypeLike ( $ Query ,$management_type_name) 15 { 16 return $query->whereHas('hasManyGoodsManagementType.hasOneGoodsManagementType',function ($query1) use($management_type_name){ 17 return $query1->where('name','like',$management_type_name); 18 }); 19 }
Middle of the table model
/* * Associated goods category management table * @auth jackie <2019.10.> */ public function hasOneGoodsManagementType() { return $this->hasOne(GoodsManagementType::class,'id','management_type_id'); }