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