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