Saving/Updating User Profile in Laravel 5

前端 未结 3 1044
-上瘾入骨i
-上瘾入骨i 2021-01-05 14:38

I can\'t seem to save the updated profile to the database.

In my edit.blade.php:

{!! Form::model($user, [\'method\' => \'PATCH\', \'route\' =>          


        
3条回答
  •  日久生厌
    2021-01-05 15:33

    Looks like you've not set the submission values to the user object.

    Try (Update this is for Laravel 4)

     $user = User::whereCompanyName($company_name)->firstOrFail();
     $user->field = Input::get("some_field"); // Name of the input field here
     $user->save(); // no validation implemented
     flash('You have successfully edited your profile');
     return redirect('/');
    

    EDIT

    Actually, if you're using Laravel 5 it looks like it should be:

    $user->field = Request::input('some_field'); // Name of the input field here
    $user->save(); // no validation implementedenter code here
    

提交回复
热议问题