hasMany(OwnerPriceDirectLogisticCar::class,"owner_price_direct_logistic_id","id"); } public function owners() { //货主中间表 return $this->belongsToMany(Owner::class,"owner_price_direct_logistic_owner","owner_price_direct_logistic_id","owner_id"); } public function getOwnerIdAttribute() { //获取货主ID数组 return array_column(DB::select(DB::raw("SELECT * FROM owner_price_direct_logistic_owner WHERE owner_price_direct_logistic_id = ?"),[$this->id]),"owner_id"); } }