repository = $rea; parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(ReaUserRequest $request) { $this->repository->pushCriteria(new \Lavalite\Intro\Repositories\Criteria\ReaUserCriteria()); $reas = $this->repository->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate(); $this->theme->prependTitle(trans('intro::rea.names').' :: '); return $this->theme->of('intro::user.rea.index', compact('reas'))->render(); } /** * Display the specified resource. * * @param Request $request * @param Rea $rea * * @return Response */ public function show(ReaUserRequest $request, Rea $rea) { Form::populate($rea); return $this->theme->of('intro::user.rea.show', compact('rea'))->render(); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(ReaUserRequest $request) { $rea = $this->repository->newInstance([]); Form::populate($rea); return $this->theme->of('intro::user.rea.create', compact('rea'))->render(); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(ReaUserRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $rea = $this->repository->create($attributes); $this->responseCode = 201; $this->responseMessage = trans('messages.success.created', ['Module' => trans('intro::rea.name')]); $this->responseRedirect = trans_url('/user/intro/rea'); return $this -> respond($request); } 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 Rea $rea * * @return Response */ public function edit(ReaUserRequest $request, Rea $rea) { Form::populate($rea); return $this->theme->of('intro::user.rea.edit', compact('rea'))->render(); } /** * Update the specified resource. * * @param Request $request * @param Rea $rea * * @return Response */ public function update(ReaUserRequest $request, Rea $rea) { try { $this->repository->update($request->all(), $rea->getRouteKey()); $this->responseCode = 204; $this->responseMessage = trans('messages.success.updated', ['Module' => trans('intro::rea.name')]); $this->responseRedirect = trans_url('/user/intro/rea'); return $this -> respond($request); } 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(ReaUserRequest $request, Rea $rea) { try { $this->repository->delete($rea->getRouteKey()); $this->responseCode = 204; $this->responseMessage = trans('messages.success.deleted', ['Module' => trans('intro::rea.name')]); $this->responseRedirect = trans_url('/user/intro/rea'); return $this -> respond($request); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } }