0
// method untuk insert data ke table d_rak
    public function store(Request $request)
    {
        $data=new User();
        $data->name=$request->get('name');
        $data->username=$request->get('username');
        $data->nip=$request->get('nip');
        $data->level=$request->get('level');
        $data->email=$request->get('email');
        $data->password=$request->get('password');
        $data->save();

    return redirect ('/users')->with('alert-success','Berhasil Menambahkan Data!');

    }
Yasin Patel
  • 5,624
  • 8
  • 31
  • 53
El shaa
  • 109
  • 2
  • 8

3 Answers3

4

Try this

use Illuminate\Support\Facades\Hash;
$data->password= Hash::make($request->get('password'));
albus_severus
  • 3,626
  • 1
  • 13
  • 25
1

Simply use bcrypt helper.

$data->password = bcrypt($request->get('password'));

or Hash facade.

$data->password = Hash::make($request->get('password'));
Harun
  • 1,137
  • 1
  • 9
  • 7
0

For use in controller:

$request->user()->fill([
            'password' => Hash::make($request->newPassword)
        ])->save();

And check if is the correct password

The check method allows you to verify that a given plain-text string corresponds to a given hash. However, if you are using the LoginController included with Laravel, you will probably not need to use this directly, as this controller automatically calls this method:

if (Hash::check('plain-text', $hashedPassword)) {
    // The passwords match...
}