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