当前位置:网站首页>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 UserSeeder
2. 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
边栏推荐
- API data interface for announcement of Hong Kong listed companies
- ESP32系列--ESP32各个系列对比
- leetcode:1504. 统计全 1 子矩形的个数
- Go language - use of goroutine coroutine
- 在宇宙的眼眸下,如何正确地关心东数西算?
- Py之toad:toad的简介、安装、使用方法之详细攻略
- 测试 H5 和小程序的区别,你真的知道吗?
- Development of digital Tibetan product system NFT digital Tibetan product system exception handling source code sharing
- ES mapping之keyword;term查询添加keyword查询;更改mapping keyword类型
- STM32F1与STM32CubeIDE编程实例-WS2812B全彩LED驱动(基于SPI+DMA)
猜你喜欢
Research on MySQL composite index
IDEA连接mysql自定义生成实体类代码
Explore cloud native databases and take a broad view of future technological development
pgsql查询分组中某个字段最大或者最小的一条数据
Convolution kernel and characteristic graph visualization
ES mapping之keyword;term查询添加keyword查询;更改mapping keyword类型
探索云原生数据库,纵观未来科技发展
成功解决:selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This versi
MySQL日志管理、备份与恢复
Method of establishing unity thermodynamic diagram
随机推荐
成功解决:selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This versi
Development of B2B transaction collaborative management platform for kitchen and bathroom electrical appliance industry and optimization of enterprise inventory structure
Brief discussion on the implementation framework of enterprise power Bi CI /cd
Go language -init() function - package initialization
v-for 中 key的作用和原理
Don't underestimate the integral mall. It can play a great role
C language ---18 function (user-defined function)
MySQL title
Daily knowledge popularization
Digital business cloud: strengthen supplier management and promote efficient collaboration between air transport enterprises and suppliers
09_ An efficient memory method
leetcode:1504. 统计全 1 子矩形的个数
【无标题】
R语言实战应用精讲50篇(二十三)-贝叶斯理论重要概念: 可信度Credibility, 模型Models, 和参数Parameters
Database considerations
Halcon draw area into picture
港股上市公司公告 API 数据接口
不要小看了积分商城,它的作用可以很大
ES mapping之keyword;term查询添加keyword查询;更改mapping keyword类型
Solution of channel management system for food and beverage industry: realize channel digital marketing layout