repository = $push_postback; parent::__construct(); } /** * Display a list of push_postback. * * @return Response */ public function index(PushPostbackAdminWebRequest $request) { if ($request->wantsJson()) { $push_postbacks = $this->repository->setPresenter('\\Guru\\PushPostback\\Repositories\\Presenter\\PushPostbackListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->all(); return response()->json($push_postbacks, 200); } $this ->theme->prependTitle(trans('push_postback::push_postback.names').' :: '); return $this->theme->of('push_postback::admin.push_postback.index')->render(); } /** * Display push_postback. * * @param Request $request * @param Model $push_postback * * @return Response */ public function show(PushPostbackAdminWebRequest $request, PushPostback $push_postback) { if (!$push_postback->exists) { return response()->view('push_postback::admin.push_postback.new', compact('push_postback')); } Form::populate($push_postback); return response()->view('push_postback::admin.push_postback.show', compact('push_postback')); } /** * Show the form for creating a new push_postback. * * @param Request $request * * @return Response */ public function create(PushPostbackAdminWebRequest $request) { $push_postback = $this->repository->newInstance([]); Form::populate($push_postback); return response()->view('push_postback::admin.push_postback.create', compact('push_postback')); } /** * Create new push_postback. * * @param Request $request * * @return Response */ public function store(PushPostbackAdminWebRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id('admin.web'); $push_postback = $this->repository->create($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('push_postback::push_postback.name')]), 'code' => 204, 'redirect' => trans_url('/admin/push_postback/push_postback/'.$push_postback->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, ], 400); } } /** * Show push_postback for editing. * * @param Request $request * @param Model $push_postback * * @return Response */ public function edit(PushPostbackAdminWebRequest $request, PushPostback $push_postback) { Form::populate($push_postback); return response()->view('push_postback::admin.push_postback.edit', compact('push_postback')); } /** * Update the push_postback. * * @param Request $request * @param Model $push_postback * * @return Response */ public function update(PushPostbackAdminWebRequest $request, PushPostback $push_postback) { try { $attributes = $request->all(); $push_postback->update($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('push_postback::push_postback.name')]), 'code' => 204, 'redirect' => trans_url('/admin/push_postback/push_postback/'.$push_postback->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/push_postback/push_postback/'.$push_postback->getRouteKey()), ], 400); } } /** * Remove the push_postback. * * @param Model $push_postback * * @return Response */ public function destroy(PushPostbackAdminWebRequest $request, PushPostback $push_postback) { try { $t = $push_postback->delete(); return response()->json([ 'message' => trans('messages.success.deleted', ['Module' => trans('push_postback::push_postback.name')]), 'code' => 202, 'redirect' => trans_url('/admin/push_postback/push_postback/0'), ], 202); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/push_postback/push_postback/'.$push_postback->getRouteKey()), ], 400); } } }