Exemplo n.º 1
0
 /**
  * Save profile data
  * @param type $id
  * @param type ProfileRequest $request
  * @return type Response
  */
 public function postProfile(ProfileRequest $request)
 {
     $user = User::where('id', '=', Auth::user()->id)->first();
     $user->gender = $request->get('gender');
     $user->save();
     if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') {
         if ($request->input('gender') == 1) {
             $name = 'avatar5.png';
             $destinationPath = 'lb-faveo/media/profilepic';
             $user->profile_pic = $name;
         } elseif ($request->input('gender') == 0) {
             $name = 'avatar2.png';
             $destinationPath = 'lb-faveo/media/profilepic';
             $user->profile_pic = $name;
         }
     }
     if (Input::file('profile_pic')) {
         //$extension = Input::file('profile_pic')->getClientOriginalExtension();
         $name = Input::file('profile_pic')->getClientOriginalName();
         $destinationPath = 'lb-faveo/media/profilepic';
         $fileName = rand(00, 9999) . '.' . $name;
         //echo $fileName;
         Input::file('profile_pic')->move($destinationPath, $fileName);
         $user->profile_pic = $fileName;
     } else {
         $user->fill($request->except('profile_pic', 'gender'))->save();
         return redirect()->back()->with('success1', 'Profile Updated sucessfully');
     }
     if ($user->fill($request->except('profile_pic'))->save()) {
         return redirect()->back()->with('success1', 'Profile Updated sucessfully');
     }
 }
Exemplo n.º 2
0
 /**
  * post profile edit
  * @param type int $id
  * @param type ProfileRequest $request
  * @return type Redirect
  */
 public function postProfileedit(ProfileRequest $request)
 {
     // geet authenticated user details
     $user = Auth::user();
     $user->gender = $request->input('gender');
     $user->save();
     // checking availability of agent profile ppicture
     if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') {
         if ($request->input('gender') == 1) {
             $name = 'avatar5.png';
             $destinationPath = 'lb-faveo/media/profilepic';
             $user->profile_pic = $name;
         } elseif ($request->input('gender') == 0) {
             $name = 'avatar2.png';
             $destinationPath = 'lb-faveo/media/profilepic';
             $user->profile_pic = $name;
         }
     }
     // checking if the post system includes agent profile picture upload
     if (Input::file('profile_pic')) {
         // fetching picture name
         $name = Input::file('profile_pic')->getClientOriginalName();
         // fetching upload destination path
         $destinationPath = 'lb-faveo/media/profilepic';
         // adding a random value to profile picture filename
         $fileName = rand(00, 9999) . '.' . $name;
         // moving the picture to a destination folder
         Input::file('profile_pic')->move($destinationPath, $fileName);
         // saving filename to database
         $user->profile_pic = $fileName;
     } else {
         try {
             $user->fill($request->except('profile_pic', 'gender'))->save();
             return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
         } catch (Exception $e) {
             return Redirect::route('profile')->with('success', $e->errorInfo[2]);
         }
     }
     if ($user->fill($request->except('profile_pic'))->save()) {
         return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
     }
 }