How to update the data of a registry Laravel 5.2?

0

I'm moving on Laravel soon, I have name, email and password and wanted to know how do I update this data with a form.

<div class="container">
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <div class="panel panel-default">
                <div class="panel-heading"><h4>{{ Auth::user()->name }}</h4> </div>

                <div class="panel-body">
                    <form>
                      <div class="form-group">
                        <label for="exampleInputPassword1">Editar Nome</label>
                         <input id="name" type="text" class="form-control" name="name" value="">
                      </div>
                      <div class="form-group">
                        <label for="exampleInputEmail1">Novo E-mail</label>
                        <input id="email" type="email" class="form-control" name="email" value="">
                      </div>
                      <div class="form-group">
                        <label for="exampleInputPassword1">Nova Senha</label>
                        <input id="password" type="password" class="form-control" name="password">
                      </div>                     
                      <button type="submit" class="btn btn-default">Atualizar dados</button>
                       <a href="{{ url('/home') }}"><button type="button" class="btn btn-primary">Voltar</button></a>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;


use App\Http\Requests;

class ProfileController extends Controller
{
    public function editar()
    {
        return view('editar');
    }
}

I can register a user, log in, but I am in doubt as to how to do this part of updating the person's data.

    
asked by anonymous 13.05.2018 / 08:40

1 answer

0
    public function update($id)
{
    $profile = Profile::find($id);
    $profile->update(Input::all());
    return view('suaView');
}

Remembering to have the $ fillable fields registered in the model for Mass Assignment to work right and safe.

You should also add the appropriate route, for example:

Route::post('profile/{id}', 'ProfilesController@update');

I hope I have helped.

    
16.05.2018 / 17:24