hey everyone im trying to use form to update my users table
in my DB
here is my form
<form method="POST" action="/profile/update">
<div class="form-group hidden">
<input type="hidden" name="_token" value="">
<input type="hidden" name="id" value="<?php echo $user->id;?>">
<input type="hidden" name="_method" value="PATCH">
</div>
<div class="form-group">
<label for="email"><b>Name:</b></label>
<input type="text" name="name" placeholder="Please enter your email here" class="form-control" value="<?php echo $user->name;?>"/>
</div>
<div class="form-group">
<label for="email"><b>Email:</b></label>
<input type="text" name="email" placeholder="Please enter your email here" class="form-control" value="<?php echo $user->email;?>"/>
</div>
<div class="form-group">
<button type="submit" class="btn btn-default"> Submit </button>
</div>
</form>
here is my controller
<?php
namespace App\Http\Controllers;
use Auth;
use App\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class ProfileController extends Controller
{
/**
* Update user profile & make backend push to DB
**/
public function index() {
// connecting to the DB and accessing
$user = Auth::user();
//var_dump($user);
return view('profile', compact('user'));
}
public function update(Request $request) {
$request->only('name','email');
return back();
}
}
my update method
will handle the request but im not sure how to pass that data to my user table
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire