コード例 #1
0
ファイル: TestCase.php プロジェクト: captainblue2013/Lumen
 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
0
 /**
  * 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' => '*****@*****.**', 'password' => bcrypt('secret'), 'image' => 'minion3.jpg', 'role' => 0], ['name' => 'Christina Doe', 'email' => '*****@*****.**', 'password' => bcrypt('secret'), 'image' => 'minion4.jpg', 'role' => 1], ['name' => 'Demo', 'email' => '*****@*****.**', 'password' => bcrypt('demodemo'), 'image' => 'minion4.jpg', 'role' => 2], ['name' => 'Ben Doe', 'email' => '*****@*****.**', 'password' => bcrypt('secret'), 'image' => 'minion3.jpg', 'role' => 2], ['name' => 'Jessica Doe', 'email' => '*****@*****.**', 'password' => bcrypt('secret'), 'image' => 'minion4.jpg', 'role' => 3], ['name' => 'Jack Doe', 'email' => '*****@*****.**', '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
0
 /**
  * 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' => '*****@*****.**', '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
0
 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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::unguard();
     User::create(['name' => 'user', 'email' => '*****@*****.**', 'password' => 'password']);
     User::reguard();
 }
コード例 #8
0
ファイル: UsersSeeder.php プロジェクト: malyusha/new-year
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::unguard();
     factory(User::class, 10)->create();
     User::reguard();
 }