What you can do is create a route that loads a function similar to edit () but that does not receive any parameter, but you get the user's id by means of the session variable Auth :: User () - > id , this loads the logged user's data and sends it to a form so that it can be edited by the user. Then to send the data you do something similar to the previous route where you create a route to a function update () that does not receive parameters and you get the user id of the same as mentioned before and you simply update the user data.
Example
routes
Route::get('perfil/actualizar',['as'=> 'perfil.edit', 'uses' => 'UsuarioController@edit']);
Route::patch('perfil/actualizar',['as'=> 'perfil.update', 'uses' => 'UsuarioController@update']);
driver using InfyOm
public function edit(){
$usuario = $this->userRepository->findWithoutFail(Auth::User()->id);
if(empty($usuario)){
Flash::error('mensaje error');
return redirect()->back();
}
return view('editar_perfil')->with('usuario', $usuario);
}
public function update(UpdateUserRequest $request){
$usuario = $this->userRepository->findWithoutFail(Auth::User()->id);
if(empty($usuario)){
Flash::error('mensaje error');
return redirect()->back();
}
$input=$request->all();
$usuario = $this->userRepository->update($input,Auth::User()->id);
Flash::success('Perfil actualizado con éxito.');
return redirect(route('index'));
}
driver without using InfyOm
public function edit(){
$usuario = User::find(Auth::User()->id);
if(empty($usuario)){
Flash::error('mensaje error');
return redirect()->back();
}
return view('editar_perfil')->with('usuario', $usuario);
}
public function update(Request $request){
$usuario = User::find(Auth::User()->id);
if(empty($usuario)){
Flash::error('mensaje error');
return redirect()->back();
}
$usuario->fill($request->all());
$usuario->save();
Flash::success('Perfil actualizado con éxito.');
return redirect(route('index'));
}
view
<form action="{{route('perfil.update')}}" method="PATCH">
/** lo que vaya aqui **/
</form>
This way you avoid creating a whole crud to only update the prfil of the users, and if you want to add a view show () , you only do something similar to edit ()
However, if you want to use the InfyOm commands to stop a step, you can use this php artisan infyom:scaffold $MODEL_NAME --views=index,create,edit,show
Where you use - views = to specify the views you want to generate.
Here you can find more information: link