public function getSwap($account) { $ac = \App\Account::findOrFail($account); $this->currentUser->agent_account_id = $ac->id; $this->currentUser->save(); return redirect()->back()->with('message', 'Changed Account!'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request, $id) { try { $account = Account::findOrFail($id); } catch (ModelNotFoundException $e) { return redirect('account')->withErrors("Account with id " . $id . " not found"); } $input = $request::all(); $account->fill($input); try { $account->saveOrFail(); } catch (ValidationException $e) { return redirect('account/edit/' . $id)->withErrors($e->getErrors())->withInput(); } return view('account.show')->with(['account' => $account, 'success' => 'Account ' . $account . ' successfully updated!']); }
public function patchUpdate($accountId) { $validator = Validator::make(Input::all(), $this->updateRules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } else { $account = Account::findOrFail($accountId); if (Gate::denies('update', $account)) { return "Hey guy, Don't try to hack, This account is not belong to you."; } if (Input::get('current_password') != $account->password) { return Redirect::back()->withErrors(['current_password' => 'Mật khẩu cũ không đúng.'])->withInput(); } $account->password = Input::get('password'); $account->save(); return Redirect::to(route('account.show', $account->id)); } }
public function update($accountId) { $rule = $this->rules; $rule['username'][2] .= ',' . $accountId; $validator = Validator::make(Input::all(), $rule); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } else { $game = Game::findOrFail(Input::get('game_id')); $user = User::findOrFail(Input::get('user_id')); $account = Account::findOrFail($accountId); $account->username = Input::get('username'); $account->password = Input::get('password'); $account->user_id = $user->id; $account->game_id = $game->id; $account->save(); return Redirect::to(route('admin.account.show', $account->id)); } }
/** * Update the specified resource in storage. *passing array for function sync * @param int $id * @return Response */ public function update($id, AccountRequest $request) { //email verification - unique $email = $request->input('email'); $accounts = Account::where('email', $email)->get(); $numOfAccount = $accounts->count(); $accountIds = $accounts->lists('id'); if ($numOfAccount == 1 && $accountIds[0] == $id) { $account = Account::findOrFail($id); $account->update($request->all()); //users - accounts Auth::user()->accounts()->sync([$id]); //account - files if ($request->file('file')) { $fileOrgName = $request->file('file')->getClientOriginalName(); $filePath = realpath('fileStorage') . '/' . $id; if (!file_exists($filePath)) { File::makeDirectory($filePath, 0775, true); } $account->files()->create(['file' => $fileOrgName]); $request->file('file')->move($filePath, $fileOrgName); } } else { Session::flash('flash_message', 'Your email already has been taken. Please try another one.'); Session::flash('flash_message_important', true); } return redirect('accounts'); }
public function attachMembers($id) { $account = Account::findOrFail($id); $team = $account->team->first(); $team = json_decode($team->theData); $members = User::whereAccountId($id); $permissions = Permission::all(); return View::make('tests/attachMemberToTeam')->with('permissions', $permissions)->with('account', $account)->with('members', $members)->with('team', $team); }
/** * Updates a account * * @param $input * @param $id * * @return array */ public function update($input, $id) { $account = $this->account->findOrFail($id); $account->update(['name' => $input->name]); return ["id" => $account->id]; }