Support the ongoing development of Laravel.io →
Forms Validation
Last updated 2 years ago.
0

probably there are validation errors. you need to show them back in the form using variable $errors.

paste code from https://laravel.com/docs/5.1/validation#quick-displaying-the-validation-errors in to your view and see what you get there

0

Hi, jerauf I advise to rework your code like this, and maybe it can resolve the problem:

public function postProfileEdit(UpdateProfileRequest $request)
{
    $profile_update = User::find(Auth::user()->id);
    $profile_update->name = Input::get('name');
    $profile_update->biography = Input::get('biography');
    $profile_update->location = Input::get('location');
    $profile_update->email = Input::get('email');
    $profile_update->email_private = Input::get('email_private');
    $profile_update->website = Input::get('website');
    $profile_update->facebook = Input::get('facebook');
    $profile_update->twitter = Input::get('twitter');
    $profile_update->google_plus = Input::get('google_plus');
    $profile_update->linkedin = Input::get('linkedin');
    $profile_update->save();

    return Redirect::to('profile'); // I advise to use the redirect->back(); or redirect->route('routeName'), and make redirect with some variables ->withSuccess('Your profile was successeful updated !') and ->withErrors($request->getErrors());
}
<?php namespace App\Http\Requests

use Auth;

class UpdateProfileRequest extends Request
{
    public function authorize() // required method
    {
        return true; // here u can handle if current user can handle the request like mini middleware. If u return false jst returns the forbidden.
    }

    public function rules()
    {
        return [
            'name' => 'required', // However, DO NOT make 'name' field for users unique, this is no sense, this is not 'username' the users can have the same names, only "auth" stuff like email, username MUST be unique.
            'email' => 'required|unique:users', // Here the your problem, u try to update yor email on save profile then email input is not changed, so it returns the error on validation and u jst don't know about it because you dont shows that errors. So to fix this stuff you just need to update it with this:
            'email' => 'required|unique:users,email,'.Auth::id() // It means the email validator excepts only user with id -> Auth::id()
        ];
    }
}
Last updated 8 years ago.
0

Thanks for the responses. Got it working.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

jerauf jerauf Joined 16 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.