本文整理汇总了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']]);
}