D:\phpStudy\WWW\api.douxiaoli.com\database\factories\ModelFactory.php

D:\phpStudy\WWW\BCCKidV1.0\vendor\fzaninotto\faker\src\Faker\Generator.php

$factory->define(App\User::class, function (Faker\Generator $faker) {

static $password;

#定义假数据长什么样子

return [

'name' => $faker->name,

'email' => $faker->unique()->safeEmail,

'password' => $password ?: $password = bcrypt('test12345'),

'api_token' => str_random(60),

'remember_token' => str_random(10),

];

});

然后在命令行中运行:

php artisan thinker

factory(‘App\User',10)->create();

这个地方的引号是英文的,csdn编辑器原因,复制出来之后是中文的,记得改成英文。

那个10表示一次生成10个假数据。

数据库结果记录:

其他可用的东东:

/**

* @property string $name

* @method string name(string $gender = null)

* @property string $firstName

* @method string firstName(string $gender = null)

* @property string $firstNameMale

* @property string $firstNameFemale

* @property string $lastName

* @property string $title

* @method string title(string $gender = null)

* @property string $titleMale

* @property string $titleFemale

*

* @property string $citySuffix

* @property string $streetSuffix

* @property string $buildingNumber

* @property string $city

* @property string $streetName

* @property string $streetAddress

* @property string $postcode

* @property string $address

* @property string $country

* @property float $latitude

* @property float $longitude

*

* @property string $ean13

* @property string $ean8

* @property string $isbn13

* @property string $isbn10

*

* @property string $phoneNumber

*

* @property string $company

* @property string $companySuffix

* @property string $jobTitle

*

* @property string $creditCardType

* @property string $creditCardNumber

* @method string creditCardNumber($type = null, $formatted = false, $separator = '-')

* @property \DateTime $creditCardExpirationDate

* @property string $creditCardExpirationDateString

* @property array $creditCardDetails

* @property string $bankAccountNumber

* @method string iban($countryCode = null, $prefix = '', $length = null)

* @property string $swiftBicNumber

* @property string $vat

*

* @property string $word

* @property string|array $words

* @method string|array words($nb = 3, $asText = false)

* @property string $sentence

* @method string sentence($nbWords = 6, $variableNbWords = true)

* @property string|array $sentences

* @method string|array sentences($nb = 3, $asText = false)

* @property string $paragraph

* @method string paragraph($nbSentences = 3, $variableNbSentences = true)

* @property string|array $paragraphs

* @method string|array paragraphs($nb = 3, $asText = false)

* @property string $text

* @method string text($maxNbChars = 200)

*

* @method string realText($maxNbChars = 200, $indexSize = 2)

*

* @property string $email

* @property string $safeEmail

* @property string $freeEmail

* @property string $companyEmail

* @property string $freeEmailDomain

* @property string $safeEmailDomain

* @property string $userName

* @property string $password

* @method string password($minLength = 6, $maxLength = 20)

* @property string $domainName

* @property string $domainWord

* @property string $tld

* @property string $url

* @property string $slug

* @method string slug($nbWords = 6, $variableNbWords = true)

* @property string $ipv4

* @property string $ipv6

* @property string $localIpv4

* @property string $macAddress

*

* @property int $unixTime

* @property \DateTime $dateTime

* @property \DateTime $dateTimeAD

* @property string $iso8601

* @property \DateTime $dateTimeThisCentury

* @property \DateTime $dateTimeThisDecade

* @property \DateTime $dateTimeThisYear

* @property \DateTime $dateTimeThisMonth

* @property string $amPm

* @property int $dayOfMonth

* @property int $dayOfWeek

* @property int $month

* @property string $monthName

* @property int $year

* @property int $century

* @property string $timezone

* @method string amPm($max = 'now')

* @method string date($format = 'Y-m-d', $max = 'now')

* @method string dayOfMonth($max = 'now')

* @method string dayOfWeek($max = 'now')

* @method string iso8601($max = 'now')

* @method string month($max = 'now')

* @method string monthName($max = 'now')

* @method string time($format = 'H:i:s', $max = 'now')

* @method string unixTime($max = 'now')

* @method string year($max = 'now')

* @method \DateTime dateTime($max = 'now', $timezone = null)

* @method \DateTime dateTimeAd($max = 'now', $timezone = null)

* @method \DateTime dateTimeBetween($startDate = '-30 years', $endDate = 'now')

* @method \DateTime dateTimeInInterval($date = '-30 years', $interval = '+5 days', $timezone = null)

* @method \DateTime dateTimeThisCentury($max = 'now', $timezone = null)

* @method \DateTime dateTimeThisDecade($max = 'now', $timezone = null)

* @method \DateTime dateTimeThisYear($max = 'now', $timezone = null)

* @method \DateTime dateTimeThisMonth($max = 'now', $timezone = null)

*

* @property string $md5

* @property string $sha1

* @property string $sha256

* @property string $locale

* @property string $countryCode

* @property string $countryISOAlpha3

* @property string $languageCode

* @property string $currencyCode

* @property boolean $boolean

* @method boolean boolean($chanceOfGettingTrue = 50)

*

* @property int $randomDigit

* @property int $randomDigitNotNull

* @property string $randomLetter

* @property string $randomAscii

* @method int randomNumber($nbDigits = null, $strict = false)

* @method int|string|null randomKey(array $array = array())

* @method int numberBetween($min = 0, $max = 2147483647)

* @method float randomFloat($nbMaxDecimals = null, $min = 0, $max = null)

* @method mixed randomElement(array $array = array('a', 'b', 'c'))

* @method array randomElements(array $array = array('a', 'b', 'c'), $count = 1, $allowDuplicates = false)

* @method array|string shuffle($arg = '')

* @method array shuffleArray(array $array = array())

* @method string shuffleString($string = '', $encoding = 'UTF-8')

* @method string numerify($string = '###')

* @method string lexify($string = '????')

* @method string bothify($string = '## ??')

* @method string asciify($string = '****')

* @method string regexify($regex = '')

* @method string toLower($string = '')

* @method string toUpper($string = '')

* @method Generator optional($weight = 0.5, $default = null)

* @method Generator unique($reset = false, $maxRetries = 10000)

* @method Generator valid($validator = null, $maxRetries = 10000)

*

* @method integer biasedNumberBetween($min = 0, $max = 100, $function = 'sqrt')

*

* @property string $macProcessor

* @property string $linuxProcessor

* @property string $userAgent

* @property string $chrome

* @property string $firefox

* @property string $safari

* @property string $opera

* @property string $internetExplorer

* @property string $windowsPlatformToken

* @property string $macPlatformToken

* @property string $linuxPlatformToken

*

* @property string $uuid

*

* @property string $mimeType

* @property string $fileExtension

* @method string file($sourceDirectory = '/tmp', $targetDirectory = '/tmp', $fullPath = true)

*

* @method string imageUrl($width = 640, $height = 480, $category = null, $randomize = true, $word = null, $gray = false)

* @method string image($dir = null, $width = 640, $height = 480, $category = null, $fullPath = true, $randomize = true, $word = null)

*

* @property string $hexColor

* @property string $safeHexColor

* @property string $rgbColor

* @property array $rgbColorAsArray

* @property string $rgbCssColor

* @property string $safeColorName

* @property string $colorName

*

* @method string randomHtml($maxDepth = 4, $maxWidth = 4)

*

*/

以上这篇laravel批量生成假数据的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

php 批量生成数量,laravel批量生成假数据的方法相关推荐

  1. php+mysqli实现批量执行插入、更新及删除数据的方法

    本文实例讲述了php+mysqli实现批量执行插入.更新及删除数据的方法.分享给大家供大家参考.具体如下: mysqli批量执行插入/更新/删除数据,函数为 multi_query(). 下面的代码只 ...

  2. 从勘界图批量提取宗地红线到shapefile工具,从CAD图中批量提取指定类型图形到shp数据实现方法。

    在实际工作中可能会遇到需要从勘界图dwg中提红线的工作,当面对成百上千的勘界图时,人工逐一提取将非常繁琐耗时.下面介绍一个利用FME从勘界图批量提取宗地红线的方法. 关注薇信工众号:"GIS ...

  3. 用matlab生成srtm,基于MATLAB的SRTM数据完善方法的实验研究

    第 36 卷第 6 期 2011 年 11 月 测绘科学 Science of Surveying and Mapping Vol. 36 No. 6 Nov. 作者简介: 董春来( 1963-) , ...

  4. (论文加源码)基于DEAP脑电数据集的脑电情绪识别(利用生成对抗性网络进行特征提取和数据扩充)

    本篇论文发表于2022年的顶级期刊,代码可以完整运行,详情见第八节或者个人主页 论文源码见个人主页:https://download.csdn.net/download/qq_45874683/876 ...

  5. 批量向数据库多张表导入数据的实现

    转载自  http://blog.csdn.net/mazhaojuan/article/details/8598368 前面已经介绍过如何向数据库的一张表中批量导入数据,详情见博客<项目经验- ...

  6. [贝聊科技]如何在iOS开发中更好的做假数据?

    当工期比较紧的时候,项目开发中会经常出现移动端等待后端接口数据的情形,不但耽误项目进度,更让人有种无奈的绝望.所以在开发中,我们常常自己做些假数据,以方便开发和UI调试.然而做假数据方法不同,效率和安 ...

  7. laravel批量生成假数据

    D:\phpStudy\WWW\api.douxiaoli.com\database\factories\ModelFactory.php D:\phpStudy\WWW\BCCKidV1.0\ven ...

  8. Shell脚本批量创建用户并随机生成密码

    Shell脚本批量创建用户并随机生成密码 要求:批量创建10个系统账号oldboy01-oldboy10,并设置生成密码(密码不同). 实现脚本: #!/bin/bash #Question3 for ...

  9. excel怎么设置一个按钮就一点就生成一个表_条码生成软件如何批量生成DPD条码...

    之前有介绍过关于DPD条码的编码方式,校验算法,制作方法等等信息,今天主要给大家介绍一下如何用条码生成软件批量生成DPD条码.以Excel表为例,批量导入Excel表数据批量生成DPD条码. 1.数据 ...

最新文章

  1. hexo使用jenkins自动部署到阿里云
  2. 通过Runtime源码了解关联对象的实现
  3. 在 OS X 中使用 OpenResty
  4. JavaScript 中 JSON.parse()和JSON.stringify()
  5. 宅男程序员给老婆的计算机课程之8:控制器
  6. 深度学习神经网络:改善与优化的方法
  7. 百度蜘蛛(BaiduSpider)IP段详细情况介绍
  8. C++ 重载new和delete运算符
  9. 程序员2线城市月薪25k,父母让他去北京一家16K国企,网友:去啊
  10. 《梦断代码》读书笔记——第3、4、5章
  11. 编程规范 —— 变量的命名
  12. jQuery入门笔记
  13. CentOS7.6安装docker
  14. proposal中文翻译_proposal是什么意思_ proposal的翻译_音标_读音_用法_例句_爱词霸在线词典...
  15. 没有公网IP,怎么实现外网访问内网视频监控
  16. 【LeetCode】86. 分隔链表
  17. 2012-11-26四六级词汇#9317;-----…
  18. 【艺术硕士论文】现代婚嫁服饰中传统缠花艺术的运用分析(节选)
  19. xp系统桌面没有计算机,在xp系统中,为什么桌面所有图标都消失?
  20. R语言3.6版本安装ggplot2报错解决方法

热门文章

  1. openstack Swift Grizzly TypeError: dist must be a Distribution instance
  2. 普通手机安装谷歌商店上的app
  3. 没有人工智能就没有ChatGPT,人工智能有哪些社会价值?
  4. 色盲测试,没人能过6关!
  5. javascript简单写出国际象棋棋盘
  6. 内审员和外审员哪个含金量高一点?
  7. python字符串常用函数
  8. 开源精选 - Spark个性化推荐算法
  9. Facebook发起Deepfakes检测挑战赛!悬赏1000万美元,打假AI换脸...
  10. Python数据分析18——公务员工资数据分析