当前位置: 首页>>代码示例>>PHP>>正文


PHP User::create方法代码示例

本文整理汇总了PHP中app\User::create方法的典型用法代码示例。如果您正苦于以下问题:PHP User::create方法的具体用法?PHP User::create怎么用?PHP User::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\User的用法示例。


在下文中一共展示了User::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * Create new record
  *
  * @param array $attributes
  * @return static
  */
 public function create(array $attributes = array())
 {
     if (!isset($attributes['activated'])) {
         $attributes['activated'] = 0;
     }
     return $this->model->create($attributes);
 }
开发者ID:vnzacky,项目名称:dog,代码行数:13,代码来源:EloquentUserRepository.php

示例2: create

 /**
  * Create a new user and attache the default Auth user role.
  *
  * @param array $data
  * @param $pass
  * @return static
  */
 public function create(array $data, $pass)
 {
     $userData = $this->model->create($data);
     $authUserRole = $this->roleRepository->findById(2);
     $userData->attachRole($authUserRole);
     event(new Created($userData, $pass));
     return $userData;
 }
开发者ID:amitavroy,项目名称:mywall,代码行数:15,代码来源:EloquentUser.php

示例3: getUserId

 /**
  * ユーザIDを取得
  * @param Request $request
  * @return mixed
  */
 public function getUserId(Request $request)
 {
     $userId = $request->session()->get('user_id');
     if ($userId) {
         return $userId;
     }
     $user = $this->user->create(['name' => 'unknown', 'email' => sha1(microtime()), 'password' => 'password']);
     $request->session()->set('user_id', $user->id);
     return $user->id;
 }
开发者ID:picolit,项目名称:bbs,代码行数:15,代码来源:UserService.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::create(['name' => 'Patrick Jane', 'email' => 'jane@cbi.com', 'password' => bcrypt('patrickJane'), 'is_admin' => true]);
     User::create(['name' => 'Teresa Lisbon', 'email' => 'lisbon@cbi.com', 'password' => bcrypt('teresaLisbon'), 'is_admin' => true]);
     User::create(['name' => 'Juergen Kraßnig', 'email' => 'kra16589@spengergasse.at', 'password' => bcrypt('juergen'), 'is_admin' => true]);
     User::create(['name' => 'King Mo', 'email' => 'haf16570@spengergasse.at', 'password' => bcrypt('mojtaba')]);
 }
开发者ID:starkbaum,项目名称:sucon,代码行数:12,代码来源:UsersSeeder.php

示例5: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('tbl_users')->truncate();
     $faker = \Faker\Factory::create();
     for ($i = 0; $i < 10; $i++) {
         switch (mt_rand(1, 4)) {
             case 1:
                 $insertion = 'van';
                 break;
             case 2:
                 $insertion = 'de';
                 break;
             case 3:
                 $insertion = 'van der';
                 break;
             default:
                 $insertion = '';
         }
         $city2 = "";
         $street2 = "";
         $house_nr2 = "";
         $postalcode2 = "";
         if (mt_rand(1, 2) == 1) {
             $street2 = $faker->streetName;
             $house_nr2 = $faker->numberBetween(0, 2000);
             $postalcode2 = $faker->postcode;
             $city2 = $faker->city;
         }
         \App\User::create(['username' => $faker->userName, 'password' => password_hash('password', PASSWORD_DEFAULT), 'email' => $faker->email, 'firstname' => $faker->firstName, 'lastname' => $faker->lastName, 'insertion' => $insertion, 'phone_nr' => $faker->phoneNumber, 'birthdate' => $faker->date($format = 'Y-m-d', $max = 'now') . " " . $faker->time($format = 'H:i:s', $max = 'now'), 'city' => $faker->city, 'street' => $faker->streetName, 'house_nr' => $faker->numberBetween(0, 2000), 'postalcode' => $faker->postcode, 'city2' => $city2, 'street2' => $street2, 'house_nr2' => $house_nr2, 'postalcode2' => $postalcode2]);
     }
 }
开发者ID:justmemaarten,项目名称:vlambeer,代码行数:36,代码来源:UsersTableSeeder.php

示例6: saveAdminUser

 public function saveAdminUser(SaveAdminUserPostRequest $request)
 {
     $user = User::create(['username' => $request->input('username'), 'displayname' => $request->input('displayname'), 'email' => $request->input('email'), 'password' => bcrypt($request->input('password')), 'user_role_id' => $request->input('role_id')]);
     $user->is_active = true;
     $user->save();
     return response()->json(['status' => 'success', 'message' => 'New Admin User Created.']);
 }
开发者ID:jysnkun05,项目名称:SEDPI-WebApp,代码行数:7,代码来源:UserSettingsController.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     //
     $username = $request->get('username');
     if (!$this->isUserExists($username)) {
         // Generating password hash
         $pass_hash = Hash::make($request->get('password'));
         $api_key = $this->generateApiKey();
         // insert query
         try {
             /*DB::table('users')->insert( 
               ['api_key' => $api_key
               , 'username' => $username
               , 'pass_hash' => $pass_hash
               , 'email' => $email
               , 'sdt' => $sdt]
               );*/
             User::create(array('api_key' => $api_key, 'username' => $username, 'pass_hash' => $pass_hash, 'email' => $request->get('email'), 'sdt' => $request->get('sdt')));
             return response()->json(array('error' => false, 'message' => 'User Created'));
         } catch (Exception $e) {
             return response()->json(array('error' => true, 'message' => 'Error When Create User'));
         }
     } else {
         // User with same email already existed in the db
         return response()->json(array('error' => true, 'message' => 'User Already Exist'));
     }
 }
开发者ID:nhattrungluu,项目名称:laravel,代码行数:33,代码来源:UserController.php

示例8: makeUser

 /**
  * Creates a user
  *
  * @param array $userFields
  */
 public function makeUser($userFields = [])
 {
     while ($this->times--) {
         $user_input = array_merge(['name' => $this->fake->firstName, 'email' => $this->fake->companyEmail, 'password' => 'foobar', 'password_confirmation' => 'foobar'], $userFields);
         User::create($user_input);
     }
 }
开发者ID:nljuboja,项目名称:OAuthAPI,代码行数:12,代码来源:ApiTester.php

示例9: run

 public function run()
 {
     //DB::table('forsidas')->delete();
     Forsida::create(['frettdagsins' => 'ekkert i dag']);
     User::create(['username' => 'administrator', 'password' => bcrypt('root123'), 'email' => 'admin@admin.com', 'profilephoto' => '/images/Administrator.jpg', 'firstname' => 'Alfa']);
     User::create(['username' => 'administrator2', 'password' => bcrypt('root1234'), 'email' => 'admin2@admin2.com', 'profilephoto' => '/images/Administrator.jpg', 'firstname' => 'Alfa']);
 }
开发者ID:krilliman,项目名称:Kristmann,代码行数:7,代码来源:DatabaseSeeder.php

示例10: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $adminRole = Role::create(['name' => 'Admin', 'slug' => 'admin', 'description' => '', 'level' => 1]);
     $userAdmin = User::create(['staff_code' => 'IVC00001', 'full_name' => 'Nguyen Tai Hanh', 'email' => 'nthanh@vn.isb.co.jp', 'password' => Hash::make('12345678'), 'phone_number' => '01676460626', 'user_status' => 'Working']);
     //attached role
     $userAdmin->attachRole($adminRole);
 }
开发者ID:taihanh0310,项目名称:devicemanagement,代码行数:12,代码来源:UserRoleTableSeeder.php

示例11: registerUser

 public function registerUser(Request $request)
 {
     // Reject if name, email, password and role are not provided.
     if (!$request->name || !$request->email || !$request->password) {
         return Response::json(["status" => "ERROR", "response" => "Registration failed.", "message" => "Required information (name, email, password) not provided."], 400)->header('Access-Control-Allow-Origin', '*');
     } else {
         $user = User::where('email', $request->email)->first();
         // Reject if username is taken.
         if ($user) {
             return Response::json(["status" => "OK", "response" => "Registration failed.", "message" => "An account under this email address has already been created."], 400)->header('Access-Control-Allow-Origin', '*');
         } else {
             $user = User::create(array("name" => $request->name, "email" => $request->email, "active" => 1));
             $user->user_token = md5($request->email . time());
             $user->password = md5($request->password);
             // Check if company was provided.
             if ($request->company_id) {
                 $user->company_id = $request->company_id;
                 if ($request->company_id > 0) {
                     $user->role = 2;
                 } else {
                     $user->role = 1;
                 }
             } else {
                 if ($request->resume) {
                     $user->status = 0;
                 }
             }
             // Save user, reply.
             $user->save();
             return Response::json(["status" => "OK", "response" => "Registration succeeded.", "message" => ['user' => $user, 'token' => $user->user_token]], 200)->header('Access-Control-Allow-Origin', '*');
         }
     }
 }
开发者ID:jayrav13,项目名称:cs656-backend,代码行数:33,代码来源:UserManagementController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $this->validate($request, $this->rules);
     $input = Input::all();
     User::create($input);
     return Redirect::route('users.index')->with('message', 'User created');
 }
开发者ID:lshakeel,项目名称:WE_Assignment3,代码行数:12,代码来源:UsersController.php

示例13: 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]);
         }
     }
 }
开发者ID:Adrian-Vergara,项目名称:aesap_servidor,代码行数:30,代码来源:UsuariosController.php

示例14: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $name = input::get('users_name');
     $fullname = input::get('users_fullname');
     $groupid = input::get('users_group_id');
     $email = input::get('users_email');
     $telp = input::get('users_telp');
     $jsonfollow = input::get('users_json_following');
     $description = input::get('users_description');
     $media = input::get('media_manager_id');
     $avatar = input::get('users_avatar');
     $cover = input::get('users_cover');
     $status = input::get('users_status_id');
     $device = input::get('deviceID');
     $provider = input::get('providerID');
     $deviceversion = input::get('deviceVersion');
     $brand = input::get('deviceBrand');
     $long = input::get('long');
     $lat = input::get('lat');
     $password = input::get('password');
     $cekmail = User::where('email', '=', $email)->first();
     if (isset($cekmail->id)) {
         return redirect('admin/users-detail')->with('failed', 'Failed to save, because The email have ever used !');
     }
     $field_users = array('name' => $name, 'email' => $email, 'password' => bcrypt($password));
     $user = User::create($field_users);
     $user_login = User::where('email', '=', $email)->first();
     foreach ($user_login as $key => $value) {
         $id = $user_login->id;
     }
     $datausersdetail = array('users_name' => $name, 'users_id' => $id, 'users_fullname' => $fullname, 'users_group_id' => $groupid, 'users_email' => $email, 'users_telp' => $telp, 'users_json_following' => $jsonfollow, 'users_description' => $description, 'media_manager_id' => $media, 'users_avatar' => $avatar, 'users_cover' => $cover, 'users_status_id' => $status, 'deviceID' => $device, 'providerID' => $provider, 'deviceVersion' => $deviceversion, 'deviceBrand' => $brand, 'long' => $long, 'lat' => $lat);
     table_users_detail::create($datausersdetail);
     return redirect('admin/users-detail')->with('success', 'Data saved successfully!');
 }
开发者ID:ekobudiarto,项目名称:msjd,代码行数:40,代码来源:controller_users_detail.php

示例15: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $email = $this->argument('email');
     if (is_null($email)) {
         $this->error('No e-email address given! Aborting');
         return false;
     }
     while (empty($name)) {
         $name = $this->ask('What is your name?');
     }
     $password = $this->secret('Enter a password');
     $confirm = $this->secret('Confirm the password');
     if ($password !== $confirm) {
         $this->error('The passwords do not match. Aborting');
         return false;
     }
     $admin = $this->confirm('Is this user an admin? [y/N]');
     //Actually create the user
     $user = User::create(['name' => $name, 'email' => $email, 'password' => bcrypt($password), 'admin' => $admin]);
     $apiKey = new ApiKey();
     $apiKey->key = $apiKey->generateKey();
     $apiKey->user_id = $user->id;
     $apiKey->save();
     $this->info("User successfully created with ID {$user->id}");
 }
开发者ID:Tweety-FER,项目名称:guestlist,代码行数:30,代码来源:CreateUser.php


注:本文中的app\User::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。