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 使用查询构造器配合原生sql语句查询的例子)
- laravel模型个数(laravel withCount 统计关联数量的方法)
- laravel数据库切换(实现laravel 插入操作日志到数据库的方法)
- laravel查询限制输出设置(laravel 获取某个查询的查询SQL语句方法)
- laravel接口请求模拟(Laravel 类和接口注入相关的代码)
- laravel 模块目录(Laravel框架文件上传功能实现方法示例)
- phplaravel怎么优化(laravel执行php artisan migrate报错的解决方法)
- phplaravel一般开发什么项目(laravel 去掉index.php伪静态的操作方法)
- laravel前后端分离实现排序(laravel自定义分页的实现案例offset和limit)
- laravel算法(laravel批量生成假数据的方法)
- laravel检查关联模型(Laravel 关联模型-关联新增和关联更新的方法)
- laravel模型获取表名(Laravel 对某一列进行筛选然后求和sum的例子)
- laravel框架怎么定时任务(laravel Model 执行事务的实现)
- laravel服务器设置教程(laravel框架模型、视图与控制器简单操作示例)
- laravel查询构建器原理和使用(阿里对象存储OSS在laravel框架中的使用方法)
- laravel 后台管理框架(关于Laravel-admin的基础用法总结和自定义model详解)
- 硕博期刊 SCI SSCI CSSCI分不清 一文带你看懂主流期刊分类(硕博期刊SCISSCI)
- 辱华品牌新百伦官宣新代言人IU,个别粉丝希望get爱豆同款(辱华品牌新百伦官宣新代言人IU)
- 巅峰时期被爆床照,曾被选国民最讨厌女星,IU不为人知的黑历史(巅峰时期被爆床照)
- 每天1万吨牛奶倒进下水道,美国大萧条一幕重现(每天1万吨牛奶倒进下水道)
- 如何看待美国数十万加仑牛奶倒下水道 历史又重演了(如何看待美国数十万加仑牛奶倒下水道)
- 历史惊人的相似,美国80万加仑牛奶倒入下水道,意味着什么(历史惊人的相似)
热门推荐
- C#常用的命名规范
- dedecms联动使用教程(dedecms联动类别的图文使用方法)
- python学生管理系统与数据库(python学生管理系统学习笔记)
- kubernetes最优pod数(详解kubernetes pod的编排和生命周期)
- 什么是高内聚、低耦合
- css中:first-child
- python怎么设置matlab编程(实例详解Matlab 与 Python 的区别)
- 完整版sqlserver2019卸载教程(Sql Server 2012完全卸载方法 只需8步轻松卸载)
- mybatis 一对多条件查询(mybatis collection 多条件查询的实现方法)
- django中间件路径校验(Django中使用Whoosh进行全文检索的方法)
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9