当前位置:网站首页>laravel8使用faker调用工厂填充数据
laravel8使用faker调用工厂填充数据
2022-06-24 13:04:00 【s_罐装冰块】
1.通过命令安装填充文件。
php artisan make:seeder UserSeeder2.在database找到我们的填充文件

3.在我们的填充文件中写入功能方法
//编写种子文件(使用中文包)
$faker = Factory::create('zh_CN');
//根据我们的需要来填充多少测试数据(我这里是20所以就是填充20条数据)
for ($i = 0; $i <= 20; $i++) {
//调用模型进行填充数据
UddModel::create([
'username' => $faker->name,
'password' => bcrypt('123456'),]);
// 注:在我们填充数据的过程中加入创建时间字段(updated_at)和修改时间字段(updated_at)防止填充时报错
}4.执行我们这个填充文件就可以生成填充数据
php artisan db:seed --class=UserSeeder边栏推荐
- 业务与技术双向结合构建银行数据安全管理体系
- 从谭浩强《C程序设计》上摘录的ASCII码表(常用字符与ASCII代码对照表)
- GO语言并发模型-MPG模型
- js去除字符串空格
- 【深度学习】NCHW、NHWC和CHWN格式数据的存储形式
- box-sizing
- 成功解决:selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This versi
- Unit contour creation method
- tongweb使用之端口冲突处理办法
- How to avoid placing duplicate orders
猜你喜欢

文本对比学习综述

厨卫电器行业B2B交易协同管理平台开发,优化企业库存结构

Second, the examinee must see | consolidate the preferred question bank to help the examinee make the final dash

PgSQL queries the largest or smallest data of a field in a group

ASCII code table extracted from tanhaoqiang's C program design (comparison table of common characters and ASCII codes)

初识云原生安全:云时代的最佳保障

Py之toad:toad的简介、安装、使用方法之详细攻略

OpenHarmony 1

GO语言-goroutine协程的使用

Method of establishing unity thermodynamic diagram
随机推荐
NPM package [details] (including NPM package development, release, installation, update, search, uninstall, view, version number update rules, package.json details, etc.)
[untitled]
遠程辦公之:在家露營辦公小工具| 社區征文
Win10 system problems
Qunhui synchronizes with alicloud OSS
R语言plotly可视化:使用plotly可视化数据划分后的训练集和测试集、使用不同的形状标签表征、训练集、测试集、以及数据集的分类标签(Display training and test split
数据库注意事项
AQS初探
pip uninstall all packages except builtin package
Jerrys timer0 uses the default pa13 to detect the pulse width [chapter]
不要小看了积分商城,它的作用可以很大
15 differences between MES in process and discrete manufacturing enterprises (Part 2)
食品饮料行业渠道商管理系统解决方案:实现渠道数字化营销布局
P2pdb white paper
The difference between V-IF and v-show
Daily knowledge popularization
Three efficient programming skills of go language
日常知识科普
二造考生必看|巩固优选题库助力考生最后冲刺
Generate binary tree according to preorder & inorder traversal [partition / generation / splicing of left subtree | root | right subtree]