Store logeado username?

0

I am trying to store the name of the user who updates data in a table, I have only managed to store the name of the person who saves data for the first time, but not who update, another question is; I can save only the name, not the ID, so as not to relate to the users table. . I leave part of the code here.

 public function update(Request $request, $id)
{
    //
    $this->validate($request,[
        'id_estado'=>'required',
        'observaciones'=>'required',
        'autorizacion' => Auth::user(),
        ]);
    Deposito::find($id)->update($request->all());
    return redirect()->route('depositos.autorizacion')
            ->with('success', 'Deposito actualizado');
}
    
asked by JoséOrdoñez 07.12.2017 в 17:19
source

1 answer

1

I have already solved it by changing the way in which I did the update, and using what you have told me Auth::user()->name; I am left in the following way in case someone needs it. Thanks @CamiloVasquez

public function update(Request $request, $id)
{
    //
    $deposito = Deposito::findOrFail($id);
    $deposito->id_estado = $request->id_estado;
    $deposito->observaciones = $request->observaciones;
    $deposito->autorizacion = Auth::user()->name;
    $deposito->save();
    return redirect()->route('depositos.autorizacion')
            ->with('success', 'Deposito actualizado');
}
    
answered by 07.12.2017 в 18:22