StationController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. "currentStationTask.stationTaskCommodities.commodity.barcodes",
  53. "currentStationTask.stationTaskCommodities.materialBox",
  54. "currentStationTask.stationTaskBatches.batch",
  55. "stationTypeBinMonitor",
  56. ]);
  57. if (!$station['stationTypeBinMonitor']){
  58. StationTypeBinMonitor::query()->create([
  59. 'station_id' => $station['id'],
  60. 'bin_row_length' => 4,
  61. 'bin_column_length' => 5,
  62. 'bin_wall_amount' => 2,
  63. ]);
  64. $station->load("stationTypeBinMonitor");
  65. }
  66. return view('station.monitor.show',compact('station'));
  67. }
  68. /**
  69. * Show the form for editing the specified resource.
  70. *
  71. * @param \App\Station $station
  72. * @return \Illuminate\Http\Response
  73. */
  74. public function edit(Station $station)
  75. {
  76. //
  77. }
  78. /**
  79. * Update the specified resource in storage.
  80. *
  81. * @param \Illuminate\Http\Request $request
  82. * @param \App\Station $station
  83. * @return \Illuminate\Http\Response
  84. */
  85. public function update(Request $request, Station $station)
  86. {
  87. //
  88. }
  89. /**
  90. * Remove the specified resource from storage.
  91. *
  92. * @param \App\Station $station
  93. * @return \Illuminate\Http\Response
  94. */
  95. public function destroy(Station $station)
  96. {
  97. //
  98. }
  99. }