当前位置:网站首页>Laravel8 uses faker to call factory to fill data
Laravel8 uses faker to call factory to fill data
2022-06-24 14:27:00 【s_ Canned ice】
1. Install the population file through the command .
php artisan make:seeder UserSeeder2. stay database Find our fill file

3. Write the function method in our fill file
// Write seed file ( Use Chinese package )
$faker = Factory::create('zh_CN');
// How much test data to fill according to our needs ( I am here 20 So it's filling 20 Data )
for ($i = 0; $i <= 20; $i++) {
// Call the model to fill in the data
UddModel::create([
'username' => $faker->name,
'password' => bcrypt('123456'),]);
// notes : Add the creation time field in the process of filling data (updated_at) And modify the time field (updated_at) Prevent filling errors
}4. Execute our fill file to generate fill data
php artisan db:seed --class=UserSeeder边栏推荐
- GO语言并发模型-MPG模型
- Qunhui synchronizes with alicloud OSS
- Don't underestimate the integral mall. It can play a great role
- leetcode 139. Word Break 单词拆分(中等)
- Py's toad: a detailed introduction to toad, its installation and use
- Redis interview questions
- pgsql查询分组中某个字段最大或者最小的一条数据
- 常见的单例模式&简单工厂
- 入行 4 年,跳槽 2 次,我摸透了软件测试这一行
- Keras深度学习实战(11)——可视化神经网络中间层输出
猜你喜欢

Daily knowledge popularization

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

Don't underestimate the integral mall. It can play a great role

postgresql之词法分析简介

Port conflict handling method for tongweb

测试 H5 和小程序的区别,你真的知道吗?

Linux 安装 CenOS7 MySQL - 8.0.26

MySQL日志管理、备份与恢复

In the eyes of the universe, how to correctly care about counting East and West?
![Maximum path sum in binary tree [handle any subtree, then handle the whole tree]](/img/d0/91ab1cc1851d7137a1cab3cf458302.png)
Maximum path sum in binary tree [handle any subtree, then handle the whole tree]
随机推荐
P2pdb white paper
六石管理学:垃圾场效应:工作不管理,就会变成垃圾场
leetcode:1504. Count the number of all 1 sub rectangles
智慧园区SaaS管理系统解决方案:赋能园区实现信息化、数字化管理
Explore cloud native databases and take a broad view of future technological development
Keras深度学习实战(11)——可视化神经网络中间层输出
[untitled]
Virtual machines on the same distributed port group but different hosts cannot communicate with each other
Py之toad:toad的简介、安装、使用方法之详细攻略
Halcon 绘制区域 到图片中
postgresql之List
June training (day 24) - segment tree
Database considerations
Maximum path sum in binary tree [handle any subtree, then handle the whole tree]
Redis interview questions
文本对比学习综述
[leetcode] 10. Regular expression matching
【从零开始学zabbix】一丶Zabbix的介绍与部署Zabbix
业务与技术双向结合构建银行数据安全管理体系
STM32F1与STM32CubeIDE编程实例-WS2812B全彩LED驱动(基于SPI+DMA)