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