StationTask.php 1009 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class StationTask extends Model
  5. {
  6. protected $fillable = ['status'];
  7. public function taskCommodities()
  8. { //任务商品列表
  9. return $this->belongsToMany(StationTaskCommodity::class,"station_task_children","station_task_id","station_task_table_id")
  10. ->where("station_task_table_type","station_task_commodities");
  11. }
  12. public function taskBatches()
  13. { //任务波次 目前为单个,取值时应取第一个即可
  14. return $this->belongsToMany(StationTaskBatch::class,"station_task_children","station_task_id","station_task_table_id")
  15. ->where("station_task_table_type","station_task_batches");
  16. }
  17. public function taskMaterialBoxes()
  18. { //任务料箱
  19. return $this->belongsToMany(StationTaskMaterialBox::class,"station_task_children","station_task_id","station_task_table_id")
  20. ->where("station_task_table_type","station_task_material_boxes");
  21. }
  22. }