MeasureMonitorController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\MeasuringMachine;
  4. use App\Package;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Support\Facades\DB;
  7. use Illuminate\Support\Facades\Gate;
  8. class MeasureMonitorController extends Controller
  9. {
  10. /**
  11. * Display a listing of the resource.
  12. *
  13. * @return \Illuminate\Http\Response
  14. */
  15. public function index(Request $request)
  16. {
  17. if(!Gate::allows('包裹信息-查询')){ return redirect(url('/')); }
  18. /*$sql='SELECT a.* FROM packages a WHERE id = (SELECT MAX(id) FROM packages WHERE measuring_machine_id = a.measuring_machine_id) ORDER BY a.id';
  19. $packages=DB::table(DB::raw("($sql) as t"))->get();*/
  20. $measuring_machine_id=[];
  21. /* for ($i=0;$i<count($measuringMachine);$i++){
  22. $measuring_machine_id[$i]=$measuringMachine[$i]->id;
  23. }
  24. dd($measuring_machine_id);*/
  25. $measuring_machine_id=$request->input('id');
  26. $measuringMachines=MeasuringMachine::select('id','name','code')->get();
  27. if (empty($measuringMachines)){
  28. dd($measuringMachines);
  29. if (!$measuring_machine_id){
  30. $package=Package::with('owner','paperBox','measuringMachine')->where('measuring_machine_id',$measuringMachines[0]->id)->orderBy('id','DESC')->first();
  31. }else{
  32. $package=Package::with('owner','paperBox','measuringMachine')->where('measuring_machine_id',$measuring_machine_id)->orderBy('id','DESC')->first();
  33. if (!$package){
  34. $measuringMachine=MeasuringMachine::where('id',$measuring_machine_id)->first();
  35. $package=new Package();
  36. if ($measuringMachine)$package->measuringMachine=$measuringMachine;
  37. }
  38. }
  39. }
  40. return view('weigh.measureMonitor.index',['package'=>isset($package)?$package:null,'measuringMachines'=>$measuringMachines]);
  41. }
  42. /**
  43. * Show the form for creating a new resource.
  44. *
  45. * @return \Illuminate\Http\Response
  46. */
  47. public function create()
  48. {
  49. //
  50. }
  51. /**
  52. * Store a newly created resource in storage.
  53. *
  54. * @param \Illuminate\Http\Request $request
  55. * @return \Illuminate\Http\Response
  56. */
  57. public function store(Request $request)
  58. {
  59. //
  60. }
  61. /**
  62. * Display the specified resource.
  63. *
  64. * @param int $id
  65. * @return \Illuminate\Http\Response
  66. */
  67. public function show($id)
  68. {
  69. //
  70. }
  71. /**
  72. * Show the form for editing the specified resource.
  73. *
  74. * @param int $id
  75. * @return \Illuminate\Http\Response
  76. */
  77. public function edit($id)
  78. {
  79. //
  80. }
  81. /**
  82. * Update the specified resource in storage.
  83. *
  84. * @param \Illuminate\Http\Request $request
  85. * @param int $id
  86. * @return \Illuminate\Http\Response
  87. */
  88. public function update(Request $request, $id)
  89. {
  90. //
  91. }
  92. /**
  93. * Remove the specified resource from storage.
  94. *
  95. * @param int $id
  96. * @return \Illuminate\Http\Response
  97. */
  98. public function destroy($id)
  99. {
  100. //
  101. }
  102. }