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