I'm new to Laravel framework, what I've been trying to do is to update user adress with click on the button but the problem is that after submitting none of the values in DB changes but also without getting any error returned it just get me back to the "carnetadresse" view with the old values.
I've tried to use but it return error I think it's not supported anymore
the routes
Route::resource('adresse','AdresseController');
Route::get('/carnetadresse','AdresseController@index');
Route::put('/carnetadresse','AdresseController@update');
my AdresseController
public function index()
{
$user = auth()->user();
return view('pages.carnetadresse')->with('id',$user);
}
public function update(Request $request, $id)
{
$this->validate($request, [
'pays'=>'required',
'ville'=>'required',
'adresse'=>'required',
'codepostal'=>'required',
]);
$user = auth()->user();
$user->pays = $request->input('pays');
$user->ville = $request->input('ville');
$user->adresse = $request->input('adresse');
$user->codepostal = $request->input('codepostal');
$user->save();
return redirect('/carnetadresse')->with('success','adresse updated');
}
carnetadresse.blade.php
<div class="col-main grid12-9 grid-col2-main in-col2">
<div class="my-account">
<div class="page-title adresse-title">
<h1>Mon Adresse</h1>
</div>
<form>
<form action="POST" hidden="_method" value="PUT">
@csrf
<div class="fieldset">
<input type="hidden" name="form-key" value="">
<ul class="form-list">
<li class="wide pays">
<label for="pays" class="required">
Pays
<em>*</em>
</label>
<div class="input-box">
<input type="text" name="pays" id="pays" data-beaver-id="nom-particulier" value="" title="Pays" maxlength="255" class="input-text required-entry">
</div>
</li>
<li class="wide ville">
<label for="ville" class="required">
Ville
<em>*</em>
</label>
<div class="input-box">
<input type="text" name="ville" id="ville" data-beaver-id="nom-particulier" value="" title="Ville" maxlength="255" class="input-text required-entry">
</div>
</li>
<li class="wide adresse">
<label for="adresse" class="required">
Adresse
<em>*</em>
</label>
<div class="input-box">
<input type="text" name="adresse" id="adresse" data-beaver-id="nom-particulier" value="" title="Adresse" maxlength="255" class="input-text required-entry">
</div>
</li>
<li class="wide codepostal">
<label for="codepostal" class="required">
Code Postal
<em>*</em>
</label>
<div class="input-box">
<input type="text" name="codepostal" id="codepostal" data-beaver-id="nom-particulier" value="" title="Code Postal" maxlength="255" class="input-text required-entry">
</div>
</li>
</ul>
<div class="buttons-set">
<button type="hidden" title="Soumettre" class="button" name="_method" method="PUT" style="margin-top: 10px;">
<span>
<span>Soumettre</span>
</span>
</button>
</div>
</div>
</form>
</div>
</div>
please I'm begging you if anyone knows any solution please help it's week now since I've been searching for a solution this project is for my graduation and I'm running out of time.
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2UD1XD3
via IFTTT
Aucun commentaire:
Enregistrer un commentaire