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