of($loteamentos)->skipTotalRecords()->toJson(); } public function index() { $this->auth(__FUNCTION__); $loteamentos = $this->get(Loteamento::class)->orderBy('nome')->get(); return response()->json($loteamentos, Response::HTTP_OK); } public function store(LoteamentoRequest $request) { $this->auth(__FUNCTION__); $loteamento = Loteamento::create($this->getParams($request)); return response()->json($loteamento, Response::HTTP_CREATED); } public function show($id) { $this->auth(__FUNCTION__); return response()->json($this->get(Loteamento::class, $id), Response::HTTP_OK); } public function edit($id) { $this->auth(__FUNCTION__); $loteamento = Loteamento::findOrFail($id); return response()->json( [ 'model' => [ 'nome' => $loteamento->nome, ], ], Response::HTTP_OK ); } public function update(LoteamentoRequest $request, $id) { $this->auth(__FUNCTION__); $loteamento = tap(Loteamento::findOrFail($id))->update($this->getParams($request)); return response()->json($loteamento->fresh(), Response::HTTP_OK); } private function getParams($request) { return [ 'nome' => mb_strtoupper($request->nome) ]; } public function destroy($id) { $this->auth(__FUNCTION__); Loteamento::findOrFail($id)->delete(); return response()->json(null, Response::HTTP_NO_CONTENT); } public function autocomplete() { $loteamentos = Loteamento::with([]); return datatables()->of($loteamentos)->toJson(); } }