auth(__FUNCTION__); $temposEspera = $this->get(TempoEspera::class) ->where('infraestrutura_id', $this->getCentroCustoLogado()->infraestrutura_id) ->get(); return response()->json($temposEspera, Response::HTTP_OK); } public function create() { $this->auth(__FUNCTION__); return response()->json( [ 'model' => [ 'id' => null, 'cor' => null, 'tempo' => null, ], ], Response::HTTP_OK ); } public function store(TempoEsperaRequest $request) { $this->auth(__FUNCTION__); return response()->json(TempoEspera::create($request->all())->fresh(), Response::HTTP_CREATED); } public function show($id) { $this->auth(__FUNCTION__); return response()->json($this->get(TempoEspera::class, $id), Response::HTTP_OK); } public function edit($id) { $this->auth(__FUNCTION__); return response()->json( [ 'model' => TempoEspera::findOrFail($id), ], Response::HTTP_OK ); } public function update(TempoEsperaRequest $request, $id) { $this->auth(__FUNCTION__); return response()->json(tap(TempoEspera::findOrFail($id))->update($request->all()), Response::HTTP_OK); } public function destroy($id) { $this->auth(__FUNCTION__); return response()->json(TempoEspera::findOrFail($id)->delete(), Response::HTTP_NO_CONTENT); } private function getCentroCustoLogado() { return CentroCusto::findOrFail(auth()->payload()->get('centro_custo_id')); } }