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