repository = $tabela1; $this->repository ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria')) ->pushCriteria(new \Teste\Teste\Repositories\Criteria\Tabela1UserCriteria()); parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(Tabela1Request $request) { $tabela1s = $this->repository->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate(); $this->theme->prependTitle(trans('teste::tabela1.names')); return $this->theme->of('teste::user.tabela1.index', compact('tabela1s'))->render(); } /** * Display the specified resource. * * @param Request $request * @param Tabela1 $tabela1 * * @return Response */ public function show(Tabela1Request $request, Tabela1 $tabela1) { Form::populate($tabela1); return $this->theme->of('teste::user.tabela1.show', compact('tabela1'))->render(); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(Tabela1Request $request) { $tabela1 = $this->repository->newInstance([]); Form::populate($tabela1); $this->theme->prependTitle(trans('teste::tabela1.names')); return $this->theme->of('teste::user.tabela1.create', compact('tabela1'))->render(); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(Tabela1Request $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $tabela1 = $this->repository->create($attributes); return redirect(trans_url('/user/teste/tabela1')) -> with('message', trans('messages.success.created', ['Module' => trans('teste::tabela1.name')])) -> with('code', 201); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } /** * Show the form for editing the specified resource. * * @param Request $request * @param Tabela1 $tabela1 * * @return Response */ public function edit(Tabela1Request $request, Tabela1 $tabela1) { Form::populate($tabela1); $this->theme->prependTitle(trans('teste::tabela1.names')); return $this->theme->of('teste::user.tabela1.edit', compact('tabela1'))->render(); } /** * Update the specified resource. * * @param Request $request * @param Tabela1 $tabela1 * * @return Response */ public function update(Tabela1Request $request, Tabela1 $tabela1) { try { $this->repository->update($request->all(), $tabela1->getRouteKey()); return redirect(trans_url('/user/teste/tabela1')) ->with('message', trans('messages.success.updated', ['Module' => trans('teste::tabela1.name')])) ->with('code', 204); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } /** * Remove the specified resource. * * @param int $id * * @return Response */ public function destroy(Tabela1Request $request, Tabela1 $tabela1) { try { $this->repository->delete($tabela1->getRouteKey()); return redirect(trans_url('/user/teste/tabela1')) ->with('message', trans('messages.success.deleted', ['Module' => trans('teste::tabela1.name')])) ->with('code', 204); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } }