StationController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Station;
  4. use App\StationTypeBinMonitor;
  5. use Illuminate\Database\Eloquent\Builder;
  6. use Illuminate\Http\Request;
  7. class StationController extends Controller
  8. {
  9. /**
  10. * Display a listing of the resource.
  11. *
  12. * @return void
  13. */
  14. public function index()
  15. {
  16. }
  17. public function monitorIndex()
  18. {
  19. $stations = Station::query()->with('stationType:name','parent:name')->whereHas('stationType',function($query){
  20. /** @var Builder $query */
  21. $query->where('name','料箱监视器');
  22. })->paginate(100);
  23. return view('station.monitor.index',compact('stations'));
  24. }
  25. /**
  26. * Show the form for creating a new resource.
  27. *
  28. * @return \Illuminate\Http\Response
  29. */
  30. public function create()
  31. {
  32. //
  33. }
  34. /**
  35. * Store a newly created resource in storage.
  36. *
  37. * @param \Illuminate\Http\Request $request
  38. * @return \Illuminate\Http\Response
  39. */
  40. public function store(Request $request)
  41. {
  42. //
  43. }
  44. public function show(Station $station)
  45. {
  46. //
  47. }
  48. public function monitorShow(Station $station)
  49. {
  50. // $stationTypeBinMonitor = StationTypeBinMonitor::query()->where("station_id",$station->id)->first();
  51. $station->loadMissing([
  52. "stationTasks_today.stationTaskCommodities.commodity.barcodes",
  53. "stationTasks_today.stationTaskCommodities.stationTaskMaterialBox",
  54. "stationTasks_today.stationTaskBatches.batch.owner",
  55. "stationTasks_today.stationTaskMaterialBoxes.materialBox",
  56. "stationTypeBinMonitor",
  57. ]);
  58. if (!$station['stationTypeBinMonitor']){
  59. StationTypeBinMonitor::query()->create([
  60. 'station_id' => $station['id'],
  61. 'bin_row_length' => 4,
  62. 'bin_column_length' => 5,
  63. 'bin_wall_amount' => 2,
  64. ]);
  65. $station->load("stationTypeBinMonitor");
  66. }
  67. // dd(
  68. // data_get($station['stationTasks_today'],'*.id')
  69. // ,data_get($station['stationTasks_today'],'*.stationTaskBatches.*.batch.code')
  70. // ,data_get($station['stationTasks_today'],'*.stationTaskBatches.*.id')
  71. // ,data_get($station['stationTasks_today'],'*.stationTaskBatches.*.batch.id')
  72. // ,data_get(data_get($station['stationTasks_today'],'*.stationTaskCommodities')[7],'*.id')
  73. // ,data_get(data_get($station['stationTasks_today'],'*.stationTaskCommodities')[9],'*.id')
  74. // );
  75. // $station=$station->toJson();
  76. return view('station.monitor.show',compact('station'));
  77. }
  78. /**
  79. * Show the form for editing the specified resource.
  80. *
  81. * @param \App\Station $station
  82. * @return \Illuminate\Http\Response
  83. */
  84. public function edit(Station $station)
  85. {
  86. //
  87. }
  88. /**
  89. * Update the specified resource in storage.
  90. *
  91. * @param \Illuminate\Http\Request $request
  92. * @param \App\Station $station
  93. * @return \Illuminate\Http\Response
  94. */
  95. public function update(Request $request, Station $station)
  96. {
  97. //
  98. }
  99. /**
  100. * Remove the specified resource from storage.
  101. *
  102. * @param \App\Station $station
  103. * @return \Illuminate\Http\Response
  104. */
  105. public function destroy(Station $station)
  106. {
  107. //
  108. }
  109. }