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