repository = $tabela1; parent::__construct(); } /** * Display a list of tabela1. * * @return Response */ public function index(Tabela1Request $request) { if ($request->wantsJson()) { return $this->getJson($request); } $this ->theme->prependTitle(trans('teste::tabela1.names').' :: '); return $this->theme->of('teste::admin.tabela1.index')->render(); } /** * Display a list of tabela1. * * @return Response */ public function getJson(Tabela1Request $request) { $pageLimit = $request->input('pageLimit'); $tabela1s = $this->repository ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria')) ->setPresenter('\\Teste\\Teste\\Repositories\\Presenter\\Tabela1ListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate($pageLimit); $tabela1s['recordsTotal'] = $tabela1s['meta']['pagination']['total']; $tabela1s['recordsFiltered'] = $tabela1s['meta']['pagination']['total']; $tabela1s['request'] = $request->all(); return response()->json($tabela1s, 200); } /** * Display tabela1. * * @param Request $request * @param Model $tabela1 * * @return Response */ public function show(Tabela1Request $request, Tabela1 $tabela1) { if (!$tabela1->exists) { return response()->view('teste::admin.tabela1.new', compact('tabela1')); } Form::populate($tabela1); return response()->view('teste::admin.tabela1.show', compact('tabela1')); } /** * Show the form for creating a new tabela1. * * @param Request $request * * @return Response */ public function create(Tabela1Request $request) { $tabela1 = $this->repository->newInstance([]); Form::populate($tabela1); return response()->view('teste::admin.tabela1.create', compact('tabela1')); } /** * Create new tabela1. * * @param Request $request * * @return Response */ public function store(Tabela1Request $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id('admin.web'); $tabela1 = $this->repository->create($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('teste::tabela1.name')]), 'code' => 204, 'redirect' => trans_url('/admin/teste/tabela1/'.$tabela1->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, ], 400); } } /** * Show tabela1 for editing. * * @param Request $request * @param Model $tabela1 * * @return Response */ public function edit(Tabela1Request $request, Tabela1 $tabela1) { Form::populate($tabela1); return response()->view('teste::admin.tabela1.edit', compact('tabela1')); } /** * Update the tabela1. * * @param Request $request * @param Model $tabela1 * * @return Response */ public function update(Tabela1Request $request, Tabela1 $tabela1) { try { $attributes = $request->all(); $tabela1->update($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('teste::tabela1.name')]), 'code' => 204, 'redirect' => trans_url('/admin/teste/tabela1/'.$tabela1->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/teste/tabela1/'.$tabela1->getRouteKey()), ], 400); } } /** * Remove the tabela1. * * @param Model $tabela1 * * @return Response */ public function destroy(Tabela1Request $request, Tabela1 $tabela1) { try { $t = $tabela1->delete(); return response()->json([ 'message' => trans('messages.success.deleted', ['Module' => trans('teste::tabela1.name')]), 'code' => 202, 'redirect' => trans_url('/admin/teste/tabela1/0'), ], 202); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/teste/tabela1/'.$tabela1->getRouteKey()), ], 400); } } }