本文整理匯總了PHP中App\Model\User::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::create方法的具體用法?PHP User::create怎麽用?PHP User::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類App\Model\User
的用法示例。
在下文中一共展示了User::create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
public function run()
{
$users = [['name' => 'kilowat', 'email' => 'kilowat@mail.ru', 'password' => bcrypt(123456)], ['name' => 'john', 'email' => 'john@mail.ru', 'password' => bcrypt(123456)], ['name' => 'mike', 'email' => 'mike@mail.ru', 'password' => bcrypt(123456)]];
foreach ($users as $user) {
\App\Model\User::create($user);
}
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$users = [['name' => '娃娃脾氣', 'email' => 'shellus@vip.qq.com', 'password' => '$2y$10$NGpz8lhg63otXuTQiywcYOsPrVRZwWvQ4ABx.JlklOh9SM7otx56S']];
foreach ($users as $user) {
$model = \App\Model\User::create($user);
$this->command->info($model->id);
}
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker\Factory::create();
//hapus data
DB::table('tbl_user')->truncate();
DB::table('tbl_user')->insert([['username' => 'gaby', 'nama_depan' => 'Gabriel', 'nama_belakang' => 'Fermy', 'password' => bcrypt('12345'), 'email' => 'adadeh@adaaja.com', 'alamat' => 'disini aja', 'kota' => 'Medan', 'kode_pos' => '12345', 'user_level' => 1]]);
foreach (range(1, 30) as $index) {
\App\Model\User::create(['username' => $faker->userName(), 'nama_depan' => $faker->firstName(), 'nama_belakang' => $faker->lastName(), 'password' => bcrypt('Aa12345'), 'email' => $faker->email(), 'jk' => $faker->numberBetween(1, 2), 'tempat_lahir' => $faker->city(), 'tanggal_lahir' => $faker->dateTimeBetween('-40 years', '-10 years'), 'alamat' => $faker->address(), 'kota' => $faker->city(), 'kode_pos' => $faker->postcode(), 'user_level' => 0, 'kunjungan_terakhir' => $faker->dateTimeBetween('-2 weeks', 'now'), 'kunjungan_terakhir' => $faker->dateTimeBetween('-2 weeks', 'now')]);
}
}
示例4: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$name = $this->ask('What is your name?');
$email = $this->ask('What is your email?');
$password = $this->ask('What is your password?');
$id = \App\Model\User::create(['name' => $name, 'email' => $email, 'password' => bcrypt($password)]);
if ($id) {
$this->info('user id ' . $id . ' create is sucessful');
} else {
$this->error('Something went wrong!');
}
}
示例5: postRegister
public function postRegister()
{
//驗證字段有效性
$this->validate($this->request(), $rules = array('mobile' => 'required|digits:11|unique:users', 'readlname' => 'required', 'sex' => 'required', 'birthday' => 'required', 'marriage' => 'required'), $message = ['mobile.required' => '請輸入你的手機號', 'mobile.digits' => '手機號格式不正確', 'mobile.unique' => '該手機號已被注冊', 'realname.required' => '請輸入你的真實姓名', 'sex.required' => '請選擇性別', 'birthday.required' => '請輸選擇你的生日', 'marriage' => '請選擇婚姻狀況'], $customAttributes = []);
//獲取表單數據
$reginfo = $this->request()->only(['mobile', 'realname', 'sex', 'birthday', 'marriage']);
//dd($reginfo);
//插入注冊信息
if ($users = User::create($reginfo)) {
$users->bind()->create(array('openid' => $this->request()->get('openid')));
//注冊成功,跳轉到登陸界麵
return "<script>alert('報名成功,等待客服聯係');\n\t\t\t\t</script>;";
}
}
示例6: postLogin
public function postLogin(Request $req)
{
$user = $this->fetchUserData();
if (!$user) {
$telephone = $req->get('telephone');
$name = $req->get('name');
if (empty($telephone)) {
return response()->json(['code' => 403, 'msg' => '手機號不能為空']);
}
$user = User::where('telephone', $telephone)->first();
if (!$user) {
if (empty($name)) {
return response()->json(['code' => 403, 'msg' => '用戶名不能為空']);
}
$user = User::create(['name' => $name, 'telephone' => $telephone, 'token' => uniqid('', true)]);
}
}
return response()->json(['code' => 0, 'msg' => 'success', 'data' => []])->withCookie('token', $user->token);
}
示例7: postRegister
public function postRegister()
{
$this->validate($this->request(), array('realname' => 'required', 'mobile' => 'required|size:11|unique:users,mobile', 'sex' => 'required:in:' . array_keys_impload(\App\Enum\User::$sexLang), 'birthday' => 'required|date', 'marriage' => 'required|in:' . array_keys_impload(\App\Enum\User::$marriageLang), 'like' => 'exists:users,user_id'), array('realname.required' => '請填寫真實姓名', 'mobile.required' => '請填寫手機號', 'mobile.size' => '手機號格式不正確', 'mobile.unique' => '手機號已被注冊', 'sex.required' => '請選擇您的性別', 'sex.in' => '您填寫的性別有誤', 'birthday.required' => '請填寫您的生日', 'birthday.date' => '您填寫的生日格式不正確', 'marriage.required' => '您填寫您的婚姻狀態', 'marriage.in' => '婚姻狀態不正確', 'like.exist' => '您報名的對象不存在'));
$form = $this->request()->only('realname', 'mobile', 'sex', 'birthday', 'marriage');
try {
transaction();
//創建用戶
$user = User::create($form);
if ($this->request()->has('like')) {
//創建喜歡的人
$user->like()->create(array('like_user_id' => $this->request()->get('like')));
}
//創建用戶信息
$user->info()->create(array());
//創建擇偶條件
$user->object()->create(array('sex' => $user->sex == \App\Enum\User::SEX_FEMALE ? \App\Enum\User::SEX_MALE : \App\Enum\User::SEX_FEMALE));
commit();
return $this->rest()->success($user, '報名成功,管理員審核通過後即可登錄');
} catch (\Exception $ex) {
rollback();
dd($ex->getMessage());
return $this->rest()->error('抱歉,報名失敗,請稍後再試');
}
}
示例8: getActivitysign
/**
* 簽到
*/
public function getActivitysign(Request $req)
{
$user = $this->fetchUserData();
$activityId = $req->get('activity_id');
$phone = $req->get('phone');
if ($user) {
$userId = $user->id;
} else {
if ($phone) {
$user = User::where('telephone', $phone)->first();
if (!$user) {
$user = User::create(['name' => $phone, 'telephone' => $phone, 'token' => uniqid('', true)]);
$userActivity = UserActivity::create(['user_id' => $user->id, 'activity_id' => $activityId, 'status' => 1]);
}
$userId = $user->id;
} else {
return response()->json(['code' => 10100, 'msg' => '簽到異常', 'data' => []]);
}
}
$userActivity = UserActivity::where(['user_id' => $userId, 'activity_id' => $activityId])->first();
$userActivity->status = 1;
$userActivity = $userActivity->save();
return Redirect::to('index/wel');
}
示例9: postAdd
public function postAdd(Register $register)
{
//驗證表單
$this->validate($this->request(), ['mobile' => 'required|digits:11', 'birthday' => 'required|date', 'sex' => 'required|in:' . array_keys_impload(UserEnum::$sexForm), 'password' => 'required|min:5|max:20', 'password_confirm' => 'required|required_with:password|same:password', 'marital_status' => 'in:' . array_keys_impload(UserEnum::$maritalForm), 'height' => 'digits:3|between:130,210', 'education' => 'in:' . array_keys_impload(UserEnum::$educationForm), 'salary' => 'in:' . array_keys_impload(UserEnum::$salaryForm), 'user_name' => 'required|min:2|max:15|unique:users', 'email' => 'required|email|unique:users']);
$form = $this->request()->only(['user_name', 'email', 'mobile', 'birthday', 'password', 'marital_status', 'height', 'education', 'salary', 'province', 'city', 'area']);
try {
transaction();
$user = User::create($form);
$register->delete();
commit();
return $this->success('添加成功', $user);
} catch (\Exception $exp) {
rollback();
return $this->error('抱歉,添加失敗');
}
}
示例10: getSeedFemale
public function getSeedFemale()
{
$maleName = array('醜妞', '┇ゐぅ誰,ηi卜自怞_', '心隨你痛', '情稚', '舊情人的舊習慣', '變萌變軟變淑女', '情字醉心口', '甜小妞', '我是小女銀~', '-戀夢菇涼、', '能賦深情', '蒗與矜持_', '大姐範er', '※', '那操場永終點', '怪癖小姐的怪癖是妳。', '女生要潑辣點╮', '相思賦予誰', '不敗得貂蟬', '畫個句號給今天〃', '姬兒', '聽說、你嫁給習慣', '黑市夫人', '薄情辭', '向晚蔻', '↘無良溫柔女', '℉鍵ραn感情﹏', '子兮分袂', '△檸檬之夏', '小心眼的人', 'や風吹淚落灬', '腦殘女', '牠^_^裺滴命', '冷宮妃子怨℡', '苺籽奶醬(:≡', '埋下眼淚', '↓溫гê紅脣↑', '冰雨_落花', '森裏伊人', '小河邊唱歌', '′︷謎仄的性感', 'ぺ佳日摓jūnㄣ', '短發菇涼就是帥', '→習慣ろ畩賴鈊', '女漢子輸給了裝逼的萌妹子', '赱ɡé貓步,扭ɡé蠻腰', '魑媚', '小賣部遇萌男i', '┭台qiú輭мeì《', '無心少女毒如蠍', '嫵媚給誰看#', '剪棹痮發♀朢棹魜渣', '怹辷zんΙ洅щò夣哩', '不溫柔的女子', '紙檸', '親吻鎖傦', '屌國女農i', '¢', '眼睛裏最美麗的老娘', '他說他不愛我°', '好姑娘就是不一樣', '莪緗彅短橃罘洅噯亽碴', '╔甜羙誘秂╗', '躲在街頭﹏獨自哭泣', '揂gōu囘yì~', '「貓⑦jιē」', '、我的愛人。', '魔鬼~的女神', '長晝無亽', '爛人說愛', '゛病2τài女', '捕儚sんàóㄝ', '灬γè罙貓起', '單字情書', '^此顏差矣', '︻酥聲jιαΘ女~', '疚幼', '唯餘泣歎', '灬苚揂取ηuǎη', '亽醜圈小', '姬妓', '最佳演員', '醉歌', '·°南風起等亇lαi', '七街酒', '舊照片', 'ηà年我╈⑧', '悲傷搖曳著', '含淚說分手', 'ㄣláη巷綠街灬', '你懷裏的貓^', '~', '^', '雪念', '┆⒐丆倁足ぐ', '措辭', '━孤鯎等ηι—', '︶χiū稚(~)意', '呆萌狐狸麽麽噠', '◆輓攜庩鉎◇', '﹎笑i戯', '吻爾之眸', '溫酒訴情深', '喜萌你', '·°九色ιц尐ηǚ', '萌物少女', '★帽衫少女', '途徑愛情', '貓眠花下○●○', '晨光如水', '有本事你愛我一輩子', '我為你真心的哭過', '良笙', '怕腥的貓ε==3', '軟聲貓吟', '千萬尐囡夢', 'ε飛翔の瘋τù子ˇ', '喜笑顏開^', '~', '^', '辣椒病女', '︶沐年廴χìа', '軟甜野妹', '安與雪', 'うηáη街浪亽╮', '╮ɡū浪寡ㄝ支╭', '頭よ藏zんe觸角ゞ', '原諒我太野性', '﹏ー懜dυΘ年〆', '見蝴蝶飛越森林', '妓要從良', '一往癡心', '想哭、卻沒了淚', '→zι由初о勿☆', '︶zěη庅⒐動情', '古俗', '★`χυ多ηiaη前');
$provinces = array('北京' => array('北京'), '天津' => array('天津'), '重慶' => array('重慶'), '上海' => array('上海'), '內蒙古' => array('赤峰', '呼和浩特', '巴彥淖爾', '錫林郭勒', '二連浩特', '包頭', '烏海', '通遼'));
$strocks = array('漢族', '蒙古族', '回族');
foreach ($maleName as $name) {
$province = array_rand($provinces);
$city = arand($provinces[$province]);
$province2 = array_rand($provinces);
$city2 = arand($provinces[$province2]);
$strock = arand($strocks);
$form = array('user_name' => $name, 'realname' => $name, 'mobile' => rand(130, 189) . rand(1000, 9999) . rand(1000, 9999), 'sex' => \App\Enum\User::SEX_FEMALE, 'birthday' => rand(1983, 1997) . '-' . rand(1, 12) . '-' . rand(1, 29), 'work_province' => $province, 'work_city' => $city, 'level' => arand(array(1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3)), 'salary' => arand(array(1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9)), 'marriage' => arand(array(1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3)), 'education' => arand(array(1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 7)), 'house' => rand(1, 5), 'children' => arand(array(1, 1, 1, 1, 1, 1, 2)), 'height' => rand(155, 175), 'status' => \App\Enum\User::STATUS_OK);
try {
transaction();
//創建用戶
$user = User::create($form);
//創建用戶詳情
$user->info()->save(new UserInfo(array('stock' => $strock, 'origin_province' => $province2, 'origin_city' => $city2)));
//創建擇偶對象
$ageStart = rand(18, 39);
$ageEnd = rand($ageStart + 1, $ageStart + 10);
$heightStart = rand(170, 190);
$heightEnd = rand($heightStart + 3, $heightStart + 20);
$province3 = array_rand($provinces);
$city3 = arand($provinces[$province3]);
$user->object()->save(new UserObject(array('sex' => \App\Enum\User::SEX_MALE, 'salary_start' => arand(array(null, null, null, 1, 2, 3, 3, 4)), 'salary_end' => arand(array(null, null, null, 5, 6, 7)), 'marriage' => arand(array(null, null, null, 1, 1, 1, 2)), 'education' => arand(array(null, null, null, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6)), 'house' => arand(array(null, null, null, 1, 2, 3, 4, 5)), 'children' => arand(array(null, null, null, null, 1, 1, 1, 1, 1, 1, 2)), 'height_start' => $heightStart, 'height_end' => $heightEnd, 'age_start' => $ageStart, 'age_end' => $ageEnd, 'work_province' => $province3, 'work_city' => $city3)));
//創建推薦數據
for ($i = rand(0, 2); $i <= 2; $i++) {
if ($i) {
$user->recommend()->save(new UserRecommend(array('page' => $i, 'order' => rand(0, 100))));
}
}
echo '<span style="color:green">創建成功,ID:' . $user->user_id . "</span><br>";
commit();
} catch (\Exception $ex) {
rollback();
echo '<span style="color:red">' . $name . '創建失敗!,原因:' . $ex->getMessage() . "</span><br/><br/>";
}
}
}
示例11: create
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
public function create(array $data)
{
return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
}
示例12: create
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create(['username' => $data['username'], 'password' => bcrypt($data['password'])]);
}
示例13: run
public function run()
{
User::create(['name' => 'Paulo First', 'username' => 'paul', 'email' => 'paul@email.com', 'password' => password_hash("paul", PASSWORD_DEFAULT)]);
User::create(['name' => 'John Second', 'username' => 'john', 'email' => 'john@email.com', 'password' => password_hash("john", PASSWORD_DEFAULT)]);
}
示例14: create
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'role' => '2']);
}
示例15: createUser
public function createUser(array $data)
{
return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'photo' => uploadFile('img', 'photo', 'uploads'), 'desc' => $data['desc']]);
}