app/Http/Controllers/ProfilesController.php
/**
     * Update a user's profile
     *
     * @param $username
     * @return mixed
     * @throws Laracasts\Validation\FormValidationException
     */
Update a user's profile
@param $username
@return mixed
@throws Laracasts\Validation\FormValidationException
Update a user ' s profile @param $username @return mixed @throws Laracasts \ Validation \ FormValidationException
public function update($username, Request $request)
    {
        $profile_validator = $this->profile_validator($request->all());
        if ($profile_validator->fails()) {
            $this->throwValidationException(
                $request, $profile_validator
                );
            return redirect('profile/'.$user->name.'/edit')->withErrors($validator)->withInput();
        }
        $user = $this->getUserByUsername($username);
        $user->first_name           = $request->input('first_name');
        $user->last_name            = $request->input('last_name');
        $user->save();
        $input = Input::only('bio',
            'phone',
            'skype_user',
            'profile_pic');
        if ($user->profile == null) {
            $profile = new Profile;
            $user->profile()->save($profile);
        } else {
            $profile = $user->profile;
        }
        $profile->bio = $request->input('bio');
        $profile->phone = $request->input('phone');
        $profile->skype_user = $request->input('skype_user');
        $pic = $profile->profile_pic;
        if(Input::file('user_profile_pic') != NULL){
            $user_profile_pic    = Input::file('user_profile_pic');
            $filename           = 'user-pic.' . $user_profile_pic->getClientOriginalExtension();
            $save_path          = storage_path() . '/users/id/' . $user->id . '/uploads/images/profile-pics/';
            File::makeDirectory($save_path, $mode = 0755, true, true);
            Image::make($user_profile_pic)->save($save_path . $filename);
            $pic = '/images/profile/' . $user->id . '/pics/' . $filename;
        }
        $profile->profile_pic = $pic;
        $user->profile()->save($profile);
        return redirect('profile/'.$user->name)->with('status', 'Perfil actualizado!');
    }
public function update ( $ username , Request $ request ) { $ profile_validator = $ this -> profile_validator ( $ request -> all ( ) ) ; if ( $ profile_validator -> fails ( ) ) { $ this -> throwValidationException ( $ request , $ profile_validator ) ; return redirect ( 'profile/' . $ user -> name . '/edit' ) -> withErrors ( $ validator ) -> withInput ( ) ; } $ user = $ this -> getUserByUsername ( $ username ) ; $ user -> first_name = $ request -> input ( 'first_name' ) ; $ user -> last_name = $ request -> input ( 'last_name' ) ; $ user -> save ( ) ; $ input = Input :: only ( 'bio' , 'phone' , 'skype_user' , 'profile_pic' ) ; if ( $ user -> profile == null ) { $ profile = new Profile ; $ user -> profile ( ) -> save ( $ profile ) ; } else { $ profile = $ user -> profile ; } $ profile -> bio = $ request -> input ( 'bio' ) ; $ profile -> phone = $ request -> input ( 'phone' ) ; $ profile -> skype_user = $ request -> input ( 'skype_user' ) ; $ pic = $ profile -> profile_pic ; if ( Input :: file ( 'user_profile_pic' ) != NULL ) { $ user_profile_pic = Input :: file ( 'user_profile_pic' ) ; $ filename = 'user-pic.' . $ user_profile_pic -> getClientOriginalExtension ( ) ; $ save_path = storage_path ( ) . '/users/id/' . $ user -> id . '/uploads/images/profile-pics/' ; File :: makeDirectory ( $ save_path , $ mode = 0755 , true , true ) ; Image :: make ( $ user_profile_pic ) -> save ( $ save_path . $ filename ) ; $ pic = '/images/profile/' . $ user -> id . '/pics/' . $ filename ; } $ profile -> profile_pic = $ pic ; $ user -> profile ( ) -> save ( $ profile ) ; return redirect ( 'profile/' . $ user -> name ) -> with ( 'status' , 'Perfil actualizado!' ) ; }
Update a user's profile
 @param $username
 @return mixed
 @throws Laracasts\Validation\FormValidationException
Update a user ' s profile @param $username @return mixed @throws Laracasts \ Validation \ FormValidationException
// CHECK IF PROFILE EXISTS JUST IN CASE // CHECK FOR USER PROFILE IMAGE FILE UPLOAD // MAKE USER FOLDER AND UPDATE PERMISSIONS // SAVE FILE TO SERVER // SAVE ROUTED PATH TO IMAGE TO DATABASE