belongsToMany(StationTaskCommodity::class,"station_task_children","station_task_id","station_task_table_id") ->where("station_task_table_type","station_task_commodities"); } public function taskBatches() { //任务波次 目前为单个,取值时应取第一个即可 return $this->belongsToMany(StationTaskBatch::class,"station_task_children","station_task_id","station_task_table_id") ->where("station_task_table_type","station_task_batches"); } public function taskMaterialBoxes() { //任务料箱 return $this->belongsToMany(StationTaskMaterialBox::class,"station_task_children","station_task_id","station_task_table_id") ->where("station_task_table_type","station_task_material_boxes"); } }