dimanche 25 février 2018

new “Metier” is created when editing a “Metier ”

when I try to edit a "Metier", a new "Metier" is created and the old one stays the same. I want to crush the old "Metier" and create a new one just by editing. Could anyone help me with this please ?

Controller

 public function edit($id)
{
$metier=Metier::find($id);
return view('metier.edit',['libelle_metier'=>$metier]);
}

/**
 * Update the specified resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
 public function update(Request $request, $id)
{
$metier=Metier::find($id);
return view('metier.edit',['libelle_metier'=>$metier]);
}

View

 <div class="form-group">
 <label for="">libelle Metier </label>
 <input type="text"  name ="libelle_metier" class="form-control"value ="
 " >
 </div>

 <div class="form-group">
 <input type="submit" value = "enregistrer" class="form-control btn btn-
 primary">
 </div>

route

Route::get('/metier', 'MetierController@index');
Route::get('/metier/create', 'MetierController@create');
Route::post('/metier', 'MetierController@store');
Route::get('/metier/{id}/show', 'MetierController@edit');
Route::get('/metier/{id}/edit', 'MetierController@edit');
Route::upd('/metier/{id}/update', 'MetierController@update');
Route::delete('/metier/{id}', 'MetierController@destroy')



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire