i have this form "Modifier Technicien" with which I will modify the information of a technician, the modifications will affect two tables of my database table user and table technician. I want my form to be autofilled with the information of the technician I chose to modify. Thank you
edit.blade.php
@extends('Layouts/app')
@extends('Layouts.master')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-10">
<h1>Modifier Technicien</h1>
<form action="" method="post">
<div class="form-group">
<label for="">Nom</label>
<input id="nom" type="text" class="form-control" name="nom" value="" required autofocus>
@if ($errors->has('nom'))
<span class="help-block">
<strong></strong>
</span>
@endif
</div>
<div class="form-group">
<label for="">Prenom</label>
<input id="prenom" type="text" class="form-control" name="prenom" value="" required autofocus>
@if ($errors->has('prenom'))
<span class="help-block">
<strong></strong>
</span>
@endif
</div>
<div class="form-group">
<label for="">Telephone</label>
<input id="tel" type="text" class="form-control" name="tel" value="" required autofocus>
@if ($errors->has('tel'))
<span class="help-block">
<strong></strong>
</span>
@endif
</div>
<div class="form-group">
<label for="">Mobile</label>
<input id="mobil" type="text" class="form-control" name="mobil" value="" required autofocus>
@if ($errors->has('mobile'))
<span class="help-block">
<strong></strong>
</span>
@endif
</div>
<div class="form-group">
<label for="">Role</label>
<input id="role" type="text" class="form-control" name="role" value="" required autofocus>
@if ($errors->has('role'))
<span class="help-block">
<strong></strong>
</span>
@endif
</div>
<div class="form-group">
<label for="">Moyenne Avis</label>
<input type="text" name ="moyenne_avis" class="form-control"value="">
</div>
<div class="form-group">
<div class="form-group">
<label for="">Etat</label>
<input type="text" name ="actif" class="form-control"value="">
</div>
<div class="form-group">
<input type="submit" value = "enregistrer" class="form-control btn btn-primary">
</div>
</form>
</div>
</div>
@endsection
controller
public function edit($id)
{
$technicien=technicien::find($id);
$users = user::orderBy('id', 'asc')->get();
return view('technicien.edit',['moyenne_avis'=>$technicien],['actif'=>$technicien],['user_id'=>$technicien])->with('user', $users);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
technicien::where('id', $id)->update($request->all());
return redirect('technicien/edit');
}
route.php
Route::get('/technicien/{id}/edit', 'TechnicienController@edit');
Route::put('/technicien/{id}', 'TechnicienController@update')-
>name('technicien.update');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire