/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, Profile $profile) { $this->validate($request, Profile::validationRules()); $profile->update($request->all()); return redirect('/profile'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, Profile $profile, Image $img) { $this->validate($request, ['photo' => 'image|max:4000', 'gender' => 'required', 'name' => 'required|max:70', 'bio' => 'max:4500', 'phone' => 'max:50', 'education' => 'max:150', 'skills' => 'max:90', 'work' => 'max:100', 'location' => 'max:100']); $user = $profile->user; //Update the User name with the new value passed $user->name = $request->input('name'); $user->save(); // Save the image $photoPath = $this->saveImage($request, $user); $profile->update($request->all()); $profile->photo = $photoPath; $profile->save(); if ($request->ajax()) { return response()->json(['success' => 1, 'data' => $user]); } return redirect()->route('admin.profiles.index')->withSuccess("Your profile has been updated..."); }