StationTaskBatch.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  5. use Illuminate\Database\Eloquent\Relations\HasMany;
  6. use Illuminate\Database\Eloquent\Relations\HasManyThrough;
  7. use Illuminate\Database\Eloquent\Relations\HasOne;
  8. use Illuminate\Database\Eloquent\Relations\MorphOne;
  9. use App\Traits\ModelLogChanging;
  10. class StationTaskBatch extends Model
  11. {
  12. use ModelLogChanging;
  13. protected $fillable=['batch_id','station_id','station_task_batch_type_id','status'];
  14. function station(): BelongsTo
  15. {
  16. return $this->belongsTo(Station::class);
  17. }
  18. function stationTask(): BelongsTo
  19. {
  20. return $this->belongsTo(StationTask::class);
  21. }
  22. public function batch(): BelongsTo
  23. { //波次
  24. return $this->belongsTo(Batch::class);
  25. }
  26. function stationTaskCommodities(): HasMany
  27. {
  28. return $this->hasMany(StationTaskCommodity::class);
  29. }
  30. function stationTaskMaterialBoxes(): HasMany
  31. {
  32. return $this->hasMany(StationTaskMaterialBox::class);
  33. }
  34. function materialBoxes(): HasManyThrough
  35. {
  36. return $this->hasManyThrough(
  37. MaterialBox::class,
  38. StationTaskMaterialBox::class,
  39. 'station_task_batch_id',
  40. 'id',
  41. 'id',
  42. 'material_box_id'
  43. );
  44. }
  45. }