Reputation: 119
// 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!');
}
Upvotes: 0
Views: 1643
Reputation: 1237
Simply use bcrypt
helper.
$data->password = bcrypt($request->get('password'));
or Hash
facade.
$data->password = Hash::make($request->get('password'));
Upvotes: 1
Reputation: 736
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...
}
Upvotes: 0
Reputation: 3702
Try this
use Illuminate\Support\Facades\Hash;
$data->password= Hash::make($request->get('password'));
Upvotes: 4