Laravel Faker 使用技巧

Laravel Faker 使用技巧
 

资料分享
GitHub : https://github.com/fzaninotto/Faker


Laravel 中获取 Faker 实例

  • $faker = app(FakerGenerator::class);

 

使用 tinker 查看 faker 假数据

// 进入 tinker 模式
$ php artisan tinker

// 获取 Faker 实例 $faker
>>> $faker = app(FakerGenerator::class);

// 查看 faker 数据
>>> $faker->name()
>>> $faker->email()
>>> $faker->sentence()
 

示例

file
 
 

更多 faker 命令#

https://github.com/fzaninotto/Faker

原文地址:https://www.cnblogs.com/mouseleo/p/13828787.html