with('stationType:name','parent:name')->whereHas('stationType',function($query){ /** @var Builder $query */ $query->where('name','料箱监视器'); })->paginate(100); return view('station.monitor.index',compact('stations')); } /** * 缓存货架 * @return Application|Factory|View */ public function cachingShelfIndex() { $stations = Station::query()->with('stationType:name','parent:name')->whereHas('stationType',function($query){ /** @var Builder $query */ $query->where('name','缓存架'); })->paginate(100); return view('station.cachingShelf.list.index',compact('stations')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // } public function show(Station $station) { // } public function monitorShow(Station $station) { $stationTypeBinMonitor = StationTypeBinMonitor::query()->where("station_id",$station->id)->first(); $station->loadMissing([ "currentStationTask.stationTaskCommodities.commodity.barcodes", "currentStationTask.stationTaskCommodities.materialBox", "currentStationTask.stationTaskBatches.batch", "currentStationTask.stationTaskMaterialBoxes.materialBox", "stationTypeBinMonitor", ]); if (!$station['stationTypeBinMonitor']){ StationTypeBinMonitor::query()->create([ 'station_id' => $station['id'], 'bin_row_length' => 4, 'bin_column_length' => 5, 'bin_wall_amount' => 2, ]); $station->load("stationTypeBinMonitor"); } return view('station.monitor.show',compact('station')); } /** * Show the form for editing the specified resource. * * @param \App\Station $station * @return \Illuminate\Http\Response */ public function edit(Station $station) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Station $station * @return \Illuminate\Http\Response */ public function update(Request $request, Station $station) { // } /** * Remove the specified resource from storage. * * @param \App\Station $station * @return \Illuminate\Http\Response */ public function destroy(Station $station) { // } /** * @param Request $request * @param $id * @return array */ public function cachingShelfApi(Request $request,$id): array { $station = Station::query()->where('id',$id)->with([ 'stationTypeBinMonitor', 'currentStationTask'=>function($query){ /** @var Builder $query */ $query->with(['stationTaskCommodities'=>function($query){ /** @var Builder $query */ $query->with(['commodity.barcodes','materialBox','batch','materialBox']); }]); } ])->first(); return ['success' => true,'data' => $station]; } }