本文整理汇总了PHP中Illuminate\Support\Facades\Hash::make方法的典型用法代码示例。如果您正苦于以下问题:PHP Hash::make方法的具体用法?PHP Hash::make怎么用?PHP Hash::make使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Hash
的用法示例。
在下文中一共展示了Hash::make方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_user
public function update_user(UserEditRequest $request)
{
$id = Auth::id();
$password = $request->get('old_password');
if (Auth::attempt(array('id' => $id, 'password' => $password))) {
$user = User::whereId($id)->firstOrFail();
$user->first_name = $request->get('first_name');
$user->last_name = $request->get('last_name');
$user->dob = $request->get('dob');
$user->email = $request->get('email');
$new_password = $request->get('password');
if ($new_password != "") {
$user->password = Hash::make($new_password);
}
$user->save();
$calendar = Calendar::where('user_id', '=', $id)->firstOrFail();
$calendar->name = $request->get('first_name');
$calendar->save();
$message = 'valid';
return $message;
} else {
$message = 'invalid';
return $message;
}
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
$person = new User();
$person->first_name = $request->input('first-name');
$person->last_name = $request->input('last-name');
$person->email = $request->input('work-email');
$person->personal_email = $request->input('personal-email');
$person->password = Hash::make(uniqid());
$person->address1 = $request->input('address-one');
$person->address2 = $request->input('address-two');
$person->zip = $request->input('postcode');
$person->city = $request->input('city');
$person->state = $request->input('state');
$person->country = $request->input('country');
$person->dob = Carbon::createFromFormat('d/m/Y', $request->input('dob'))->toDateString();
$person->work_telephone = $request->input('work-telephone');
$person->personal_telephone = $request->input('personal-telephone');
$person->gender = $request->input('gender');
$person->save();
// Placeholder face until one is submitted
$path = 'people/' . $person->id . '/face.jpg';
\Illuminate\Support\Facades\Storage::put($path, file_get_contents('http://api.adorable.io/avatar/400/' . md5($person->id . $person->email . Carbon::now()->getTimestamp()) . ''));
$person->save();
// Default job position
$person->jobPositions()->attach(1, ['primary' => true]);
// Default role
$person->roles()->attach(1, ['primary' => true]);
return redirect()->intended('/people/');
}
示例3: store
public function store(Request $request)
{
if (empty($request->get('primer_nombre')) || empty($request->get('primer_apellido')) || empty($request->get('email')) || empty($request->get('password')) || empty($request->get('id_universidad')) || empty($request->get('id_programa'))) {
return response()->json(['error' => true, 'mensaje' => 'Error, Verifique que los datos no esten vacios']);
} else {
try {
$programa_universidad = DB::table('programa_universidad')->join('programas', 'programas.id_programa', '=', 'programa_universidad.id_programa')->join('universidades', 'universidades.id_universidad', '=', 'programa_universidad.id_universidad')->where('programa_universidad.id_programa', '=', $request->get('id_programa'))->where('programa_universidad.id_universidad', '=', $request->get('id_universidad'))->where('universidades.estado', '=', 'activo')->where('programas.estado', '=', 'activo')->select('programa_universidad.id_universidad', 'programa_universidad.id_programa')->get();
if ($programa_universidad) {
$user = $request->only('primer_nombre', 'primer_apellido', 'email', 'password', 'id_universidad', 'id_programa');
if ($this->validar_email($user['email'], 0)) {
return response()->json(['error' => true, 'mensaje' => 'El Email ya se encuentra registrado']);
} else {
$user['password'] = Hash::make($user['password']);
$user['rol'] = 'estudiante';
$usuario = User::create($user);
if ($usuario) {
$token = JWTAuth::fromUser($usuario);
return response()->json(['error' => false, 'mensaje' => 'Usuario Almacenado Exitosamente', 'usuario' => $usuario, 'token' => $token]);
} else {
return response()->json(['error' => false, 'mensaje' => 'Error al registrar Usuario']);
}
}
} else {
return response()->json(['error' => false, 'mensaje' => 'Error al registrar Usuario, verifique la universidad y programa al cual quiere asociarse']);
}
} catch (\Exception $e) {
return response()->json(['error' => false, 'mensaje' => 'Error al registrar Usuario', 'excepcion' => $e]);
}
}
}
示例4: saving
function saving($model)
{
///////////
// RULES //
///////////
$rules['name'] = ['required'];
$rules['password'] = ['required', 'min:8'];
$rules['gender'] = ['required', 'in:pria,wanita'];
$rules['dob'] = ['date', 'date_format:Y-m-d'];
$rules['email'] = ['email', 'unique:users,email,' . ($model->_id ? $model->_id : 'NULL') . ',_id'];
$rules['phone'] = ['string'];
//////////////
// VALIDATE //
//////////////
$data = $model->toArray();
$data['password'] = $model->password;
$validator = Validator::make($data, $rules);
if ($validator->fails()) {
$model->setErrors($validator->messages());
return false;
}
// Hash password
if (Hash::needsRehash($data['password'])) {
$model->password = Hash::make($data['password']);
}
}
示例5: postEdit
public function postEdit(Request $request)
{
$validator = Validator::make($request->all(), ['first_name' => 'required', 'last_name' => 'required', 'gender' => ['required', 'in:male,female'], 'password' => 'min:6', 'martial_status' => ['in:single,engaged,married']]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
if ($request->has('password') && $request->has('password_confirmation')) {
if ($request->password === $request->password_confirmation) {
Auth::user()->password = Hash::make($request->password);
Auth::user()->save();
} else {
return redirect()->back()->withInput()->with('errors', ['Passwords does not match.']);
}
}
$user = Auth::user();
$user->first_name = $request->first_name;
$user->last_name = $request->last_name;
$user->gender = $request->gender;
$user->birth_date = $request->has('birth_date') ? $request->birth_date : null;
$user->phone = $request->has('phone') ? $request->phone : null;
$user->bio = $request->has('bio') ? $request->bio : null;
$user->marital_status = $request->has('marital_status') ? $request->marital_status : null;
$user->save();
return redirect()->route('profile.edit')->with('info', 'your profile has been updated');
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$data = array("email" => Input::get("email"), "first_name" => Input::get("first_name"), "last_name" => Input::get("last_name"), "password" => Input::get("password"), "repassword" => Input::get("repassword"), "groups" => Input::get("groups") == null ? array() : Input::get("groups"));
$rules = array("email" => "required|unique:users,email", "first_name" => "required", "last_name" => "required", "password" => "required|min:6", "repassword" => "required|min:6|same:password");
$validator = Validator::make($data, $rules);
if ($validator->fails()) {
return Redirect::route('admin.users.create')->withErrors($validator)->withInput();
} else {
$user = new AdminUser();
$user->email = $data['email'];
$user->first_name = $data['first_name'];
$user->last_name = $data['last_name'];
$user->password = Hash::make($data['password']);
if ($user->save()) {
$s_user = Sentry::findUserById($user->id);
foreach ($data["groups"] as $group) {
$s_user->addGroup(Sentry::findGroupById($group));
}
Session::flash('success', "Đã thêm user" . $data['email'] . " thành công");
return Redirect::route('admin.users.create');
} else {
Session::flash('error', "Xảy ra lỗi trong khi thêm user " . $data['name']);
return Redirect::route('admin.users.create');
}
}
}
示例7: saveMember
/**
* Save a new, or update an existing ward member (singular)
*
* @param array $attributes
*
* @return bool|int
*/
public function saveMember(array $attributes = [])
{
$this->first_name = $attributes['first_name'];
$this->last_name = $attributes['last_name'];
$this->spouse_name = $attributes['spouse_name'];
$replaced = preg_replace('/[\\(\\)\\-\\s]/', '', $attributes['phone']);
if (strlen($replaced) === 10) {
$phone = '(' . $replaced[0] . $replaced[1] . $replaced[2] . ') ' . $replaced[3] . $replaced[4] . $replaced[5] . '-' . $replaced[6] . $replaced[7] . $replaced[8] . $replaced[9];
} else {
$phone = $attributes['phone'];
}
$this->phone = $phone;
$this->email = $attributes['email'];
if (!empty($attributes['password'])) {
$password = trim($attributes['password']);
$this->password = Hash::make($password);
}
if (!empty($attributes['ward_id'])) {
$this->ward_id = $attributes['ward_id'];
}
if (!empty($attributes['quorum_id'])) {
$this->quorum_id = $attributes['quorum_id'];
}
if (!empty($attributes['is_admin'])) {
$this->is_admin = toBool($attributes['is_admin']);
}
if (isset($attributes['is_jr_comp'])) {
$this->is_jr_comp = toBool($attributes['is_jr_comp']);
}
return parent::save();
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Requests\UserCreationRequest $request)
{
$admin = User::create($request->all());
$admin->password = Hash::make($request->input('password'));
$admin->save();
return redirect('login');
}
示例9: run
public function run()
{
DB::table('users')->delete();
$user = new User();
$user->username = 'Leo';
$user->email = 'aito0077@gmail.com';
$user->password = Hash::make('kierkegaard');
$user->save();
$user = new User();
$user->username = 'usuario1';
$user->email = 'usuario1@test.com';
$user->password = Hash::make('usuario1');
$user->save();
$user = new User();
$user->username = 'usuario2';
$user->email = 'usuario2@test.com';
$user->password = Hash::make('usuario2');
$user->save();
$user = new User();
$user->username = 'usuario3';
$user->email = 'usuario3@test.com';
$user->password = Hash::make('usuario3');
$user->save();
$user = new User();
$user->username = 'participante1';
$user->email = 'participante1@test.com';
$user->password = Hash::make('participante1');
$user->participant = true;
$user->save();
}
示例10: create
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
$new_id = User::all()->count() > 0 ? User::orderBy('id', 'desc')->first()->id + 1 : 2400;
DB::connection('member')->table('tb_user')->insert(['mid' => $data['name'], 'password' => $data['password'], 'pwd' => Hash::make($data['password']), 'idnum' => $new_id]);
DB::connection('account')->table('accounts')->insert(['id' => $new_id, 'username' => $data['name'], 'password' => $data['password']]);
return User::create(['id' => $new_id, 'username' => $data['name'], 'password' => Hash::make($data['password']), 'role' => 'member']);
}
示例11: fire
public function fire()
{
$user = new DashboardUser();
$this->info("Provide admin credentials.\n\n");
$user->name = $this->ask('Amin name: ');
$user->email = $this->ask('Admin email: ');
$user->password = Hash::make($this->secret('Admin password: '));
$rights = [DashboardUser::CREATE];
foreach (Config::get('dashboard::models') as $key => $model) {
$rights[] = $key;
}
$user->rights = $rights;
$this->info("\n\n");
try {
$user->validate();
} catch (ValidatorException $e) {
$messages = $e->getMessageBag()->getMessages();
foreach ($messages as $message) {
foreach ($message as $_message) {
$this->error($_message);
}
}
exit;
}
$user->save();
$this->info('Done');
}
示例12: create
public static function create(array $attributes = [])
{
$patient = new Patient();
$patient->personal_id = $attributes['personal_id'];
$patient->firstname = $attributes['firstname'];
$patient->lastname = $attributes['lastname'];
$patient->birthdate = $attributes['birthdate'];
$patient->address = $attributes['address'];
$patient->gender = $attributes['gender'];
$patient->religion = $attributes['religion'];
$patient->nationality = $attributes['nationality'];
$patient->bloodtype = $attributes['bloodtype'];
$patient->tel = $attributes['tel'];
$patient->email = $attributes['email'];
$patient->remark = $attributes['remark'];
$patient->save();
// this will also create the User for authentication
$user = new User();
// duplicate personal id to username
$user->username = $patient->personal_id;
$user->password = Hash::make($attributes['password']);
$user->userable_id = $patient->id;
$user->userable_type = 'App\\Patient';
$user->save();
return $patient;
}
示例13: run
public function run()
{
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
DB::table('users')->truncate();
DB::table('users')->insert([['user_name' => env('ADMIN_USERNAME'), 'first_name' => env('ADMIN_FIRSTNAME'), 'last_name' => env('ADMIN_LASTNAME'), 'email' => env('ADMIN_EMAIL'), 'password' => Hash::make(env('ADMIN_PASSWORD')), 'is_admin' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]]);
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
}
示例14: create
/**
* Create a new user in the database.
*
* @param array $data
* @return bool
*/
public function create(array $data)
{
$user = $this->user->newInstance($data);
$user->password = Hash::make($data['password']);
$user->save();
return $user;
}
示例15: postRegister
/**
* Perform the registration.
*
* @param Request $request
* @param AppMailer $mailer
* @return \Redirect
*/
public function postRegister(Request $request, AppMailer $mailer)
{
$this->validate($request, ['name' => 'required', 'email' => 'required|email|unique:users', 'password' => 'required']);
//$user = User::create($request->all());
/*$user_data = [
'name' => $request->get('name'),
'email' => $request->get('email'),
'password' => Hash::make($request->get('password')),
'token' => 'abc'//$confirmation_code
];
print_r($user_data);
die();*/
$confirmation_code = str_random(30);
/*$user = User::create([
'name' => $request->get('name'),
'email' => $request->get('email'),
'password' => Hash::make($request->get('password')),
'token' => 'abc'//$confirmation_code
]);*/
$user = new User();
$user->name = $request->get('name');
$user->email = $request->get('email');
$user->password = Hash::make($request->get('password'));
$user->token = $confirmation_code;
$user->save();
$user_data = ['name' => $request->get('name'), 'email' => $request->get('email'), 'password' => Hash::make($request->get('password')), 'token' => $confirmation_code];
$mailer->sendEmailConfirmationTo($user_data);
// Session::flash('Please confirm your email address.');
// flash('Please confirm your email address.');
Session::put('success', 'Please confirm your email address. ');
//return redirect()->back();
return redirect('/pages/confirmMail');
}