laravel算法(laravel批量生成假数据的方法)
类别:编程学习 浏览量:127
时间:2021-10-09 00:37:17 laravel算法
laravel批量生成假数据的方法
|
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批量生成假数据的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持开心学习网。
原文链接:https://blog.csdn.net/zhezhebie/article/details/78153265
您可能感兴趣
- laravel服务器设置(基于Laravel-admin 后台的自定义页面用法详解)
- laravel 队列导入数据(laravel框架查询数据集转为数组的两种方法)
- laravel5怎么设置中间件(浅谈Laravel中的三种中间件的作用)
- laravel框架运行找不到视图(解决laravel资源加载路径设置的问题)
- laravel开发登录接口(解决laravel5中auth用户登录其他页面获取不到登录信息的问题)
- laravel查询限制输出设置(laravel 获取某个查询的查询SQL语句方法)
- laravel 模块目录(Laravel框架文件上传功能实现方法示例)
- laravel新增数据表(laravel 多图上传及图片的存储例子)
- laravel开发api支持多少并发(laravel框架 api自定义全局异常处理方法)
- laravel模型怎么使用(laravel5.1框架model类查询的实现方法)
- laravel验证码依赖(laravel5.2表单验证,并显示错误信息的实例)
- laravel自动分解大任务(Laravel如何实现自动加载类)
- laravel实现跨域访问(使用laravel和ajax实现整个页面无刷新的操作方法)
- laravel查询限制输出设置(laravel validate 设置为中文的例子验证提示为中文)
- laravel线上如何调试(解决Laravel 不能创建 migration 的问题)
- laravel怎么查询信息过滤(laravel多条件查询方法and,or嵌套查询)
- 高考数学题(高考数学题基础题占多少分)
- 没钱只能吃土(没钱要吃土了幽默短信发朋友圈)
- 今年考高会很难吗(今年高考会考试吗)
- 盘古开天地 他创造了世界,谁创造了盘古 盘古是伏羲吗(盘古开天地他创造了世界)
- 关于队徽 你了解这些么 二(关于队徽你了解这些么)
- 冬天来了手脚冰凉 真不是因为上辈子你是折翼的天使(冬天来了手脚冰凉)
热门推荐
- mysql 高效分页(MySQL 分页查询的优化技巧)
- 设置超链接宽度和高度
- docker 环境下udp双向通信怎么办(解决Docker network Create加--subnet后遇到问题)
- vue接口请求类封装(Vue接口封装的完整步骤记录)
- angular模块的组成(详解Angular结构型指令模块和样式)
- python编程ai人工智能(AI领域都在用Python即将被淘汰?网友预测未来的编程语言不会是TA)
- 如何查找MySQL中查询慢的SQL语句
- mysql完全快速清空一个表(浅谈MySQL如何优雅的做大表删除)
- apachessl证书怎么获取(Apache SSL服务器配置SSL详解)
- C# string 和 stringbuilder 的区别
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9