StationController.php 2.4 KB

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