Problem bcrypt laravel 5.5 does not work

1

Does anyone know how to put a bcrypt in the password field of this method?

   /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id) 
    {

        $request->user()->authorizeRoles(['admin']);
        $this->validate($request,['name', 'last_name', 'username', 'email', 'password'=>'required|string|min:6|confirmed', 'password_confirmation'=>'required|min:6|same:password', 'tipos_usuarios_id']); 
 
        user::find($id)->update($request->all());
        return redirect()->route('ecuentas.index')->with('success','Registro actualizado satisfactoriamente');
    }

Well, in my model, I only have this,

  protected $fillable = [
        'tipos_usuarios_id', 'name', 'last_name', 'username', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

As I could validate from a model, until now I was only doing it in the controller

    
asked by zereft 01.12.2018 в 21:28
source

1 answer

0

the validation I recommend that you do it in the model, not in the controller.

You tried to put it like this: $ this- > validate ($ request, ['name', 'last_name', 'username', 'email', 'password' = > Bcrypt ('123456')

This validation is done in the model ... 'required | string | min: 6 | confirmed'

    
answered by 01.12.2018 в 21:35