本文整理汇总了PHP中app\User::reguard方法的典型用法代码示例。如果您正苦于以下问题:PHP User::reguard方法的具体用法?PHP User::reguard怎么用?PHP User::reguard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\User
的用法示例。
在下文中一共展示了User::reguard方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeUser
protected function makeUser()
{
User::unguard();
$user = User::create(['email' => $this->fake->unique()->email, 'password' => $this->fake->word, 'first_name' => $this->fake->firstName, 'last_name' => $this->fake->lastName]);
User::reguard();
return $user;
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('users')->delete();
DB::table('user_roles')->delete();
User::reguard();
$users_data = [['name' => 'John Doe', 'email' => 'notauth@gmail.com', 'password' => bcrypt('secret'), 'image' => 'minion3.jpg', 'role' => 0], ['name' => 'Christina Doe', 'email' => 'auth@gmail.com', 'password' => bcrypt('secret'), 'image' => 'minion4.jpg', 'role' => 1], ['name' => 'Demo', 'email' => 'demo@demo.com', 'password' => bcrypt('demodemo'), 'image' => 'minion4.jpg', 'role' => 2], ['name' => 'Ben Doe', 'email' => 'admin@gmail.com', 'password' => bcrypt('secret'), 'image' => 'minion3.jpg', 'role' => 2], ['name' => 'Jessica Doe', 'email' => 'superadmin@gmail.com', 'password' => bcrypt('secret'), 'image' => 'minion4.jpg', 'role' => 3], ['name' => 'Jack Doe', 'email' => 'owner@gmail.com', 'password' => bcrypt('secret'), 'image' => 'minion5.jpg', 'role' => 4]];
foreach ($users_data as $data) {
$user = User::create($data);
$user->UserRoles()->save(new UserRoles($data));
}
User::unguard();
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('users')->delete();
DB::table('user_roles')->delete();
User::reguard();
$users_data = [['name' => 'Manfred Walder', 'email' => 'office@manfredwalder.at', 'password' => bcrypt('vald1234'), 'image' => 'minion3.jpg', 'role' => 4]];
foreach ($users_data as $data) {
$user = User::create($data);
$user->UserRoles()->save(new UserRoles($data));
}
User::unguard();
}
示例4: signup
public function signup(Request $request)
{
$signupFields = Config::get('boilerplate.signup_fields');
$hasToReleaseToken = Config::get('boilerplate.signup_token_release');
$userData = $request->only($signupFields);
$validator = Validator::make($userData, Config::get('boilerplate.signup_fields_rules'));
if ($validator->fails()) {
throw new ValidationHttpException($validator->errors()->all());
}
User::unguard();
$user = User::create($userData);
User::reguard();
if (!$user->id) {
return $this->response->error('could_not_create_user', 500);
}
if ($hasToReleaseToken) {
return $this->login($request);
}
return $this->response->created();
}
示例5: create
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
public function create(array $data)
{
User::unguard();
$user = User::create(['name' => $data['name'], 'email' => $data['email'], 'phone' => $data['phone'], 'password' => bcrypt($data['password'])]);
User::reguard();
$role = new UserRole();
$role->user_id = $user->id;
$role->role_id = 2;
$role->save();
/**
* Send a welcome message
*/
$message = "Hi " . $data['name'] . ". Your account has been activated. Have a good day";
send_message($data['phone'], $message);
/**
* Send email for account creation
*/
Mail::send('emails.register', compact('user'), function ($message) use($user) {
$message->from(get_option('sent_from'), get_option('app'));
$message->to($user->email, $user->name)->subject(get_option('app') . ' Registration Successful');
});
return $user;
}
示例6: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create(Request $request)
{
if ($request->method() == 'POST') {
$this->validate($request, $this->user_rule);
$user = $request->except('_token', 'confirm_password', 'roles');
$user['password'] = bcrypt($request->input('password'));
$user['created_at'] = current_time();
$user['phone'] = remove_symbols($request->input('phone'));
User::unguard();
$addUser = User::create($user);
User::reguard();
if ($addUser) {
$role = new UserRole();
$role->user_id = $addUser->id;
$role->role_id = $request->input('roles');
$role->save();
return redirect()->back()->with('success', 'New user added');
} else {
return redirect()->back()->with('error', 'Failed to add user');
}
} else {
return view('backend.users.add');
}
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
User::unguard();
User::create(['name' => 'user', 'email' => 'mail@mail.com', 'password' => 'password']);
User::reguard();
}
示例8: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
User::unguard();
factory(User::class, 10)->create();
User::reguard();
}