repository = $oauth_apps; parent::__construct(); } /** * Display a list of oauth_apps. * * @return Response */ public function index(OauthAppsRequest $request) { if ($request->wantsJson()) { return $this->getJson($request); } $this ->theme->prependTitle(trans('outh2_a_p_i::oauth_apps.names').' :: '); return $this->theme->of('outh2_a_p_i::admin.oauth_apps.index')->render(); } /** * Display a list of oauth_apps. * * @return Response */ public function getJson(OauthAppsRequest $request) { $pageLimit = $request->input('pageLimit'); $oauth_apps = $this->repository ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria')) ->setPresenter('\\Labrender\\Outh2API\\Repositories\\Presenter\\OauthAppsListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate($pageLimit); $oauth_apps['recordsTotal'] = $oauth_apps['meta']['pagination']['total']; $oauth_apps['recordsFiltered'] = $oauth_apps['meta']['pagination']['total']; $oauth_apps['request'] = $request->all(); return response()->json($oauth_apps, 200); } /** * Display oauth_apps. * * @param Request $request * @param Model $oauth_apps * * @return Response */ public function show(OauthAppsRequest $request, OauthApps $oauth_apps) { if (!$oauth_apps->exists) { return response()->view('outh2_a_p_i::admin.oauth_apps.new', compact('oauth_apps')); } Form::populate($oauth_apps); return response()->view('outh2_a_p_i::admin.oauth_apps.show', compact('oauth_apps')); } /** * Show the form for creating a new oauth_apps. * * @param Request $request * * @return Response */ public function create(OauthAppsRequest $request) { $oauth_apps = $this->repository->newInstance([]); Form::populate($oauth_apps); return response()->view('outh2_a_p_i::admin.oauth_apps.create', compact('oauth_apps')); } /** * Create new oauth_apps. * * @param Request $request * * @return Response */ public function store(OauthAppsRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id('admin.web'); $oauth_apps = $this->repository->create($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('outh2_a_p_i::oauth_apps.name')]), 'code' => 204, 'redirect' => trans_url('/admin/outh2_a_p_i/oauth_apps/'.$oauth_apps->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, ], 400); } } /** * Show oauth_apps for editing. * * @param Request $request * @param Model $oauth_apps * * @return Response */ public function edit(OauthAppsRequest $request, OauthApps $oauth_apps) { Form::populate($oauth_apps); return response()->view('outh2_a_p_i::admin.oauth_apps.edit', compact('oauth_apps')); } /** * Update the oauth_apps. * * @param Request $request * @param Model $oauth_apps * * @return Response */ public function update(OauthAppsRequest $request, OauthApps $oauth_apps) { try { $attributes = $request->all(); $oauth_apps->update($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('outh2_a_p_i::oauth_apps.name')]), 'code' => 204, 'redirect' => trans_url('/admin/outh2_a_p_i/oauth_apps/'.$oauth_apps->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/outh2_a_p_i/oauth_apps/'.$oauth_apps->getRouteKey()), ], 400); } } /** * Remove the oauth_apps. * * @param Model $oauth_apps * * @return Response */ public function destroy(OauthAppsRequest $request, OauthApps $oauth_apps) { try { $t = $oauth_apps->delete(); return response()->json([ 'message' => trans('messages.success.deleted', ['Module' => trans('outh2_a_p_i::oauth_apps.name')]), 'code' => 202, 'redirect' => trans_url('/admin/outh2_a_p_i/oauth_apps/0'), ], 202); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/outh2_a_p_i/oauth_apps/'.$oauth_apps->getRouteKey()), ], 400); } } }