标签:laravel框架 tps pass laravel created extend bsp 示例 mail
该库在laravel框架中默认已经存在,无需手动进行安装。使用参考文档:
https://packagist.org/packages/fzaninotto/faker
<?php use Faker\Factory; use Illuminate\Database\Seeder; class ManagerTableSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { //产生faker实例 $faker = Factory::create(‘zh_CN‘); //访问具体属性来获取数据 $data = []; for ($i = 0; $i < 100; $i++) { $line = [ ‘username‘ => $faker->userName,//生成用户名 ‘password‘ => bcrypt(123456), ‘gender‘ => rand(1, 3), ‘mobile‘ => $faker->phoneNumber,//生成手机号 ‘email‘ => $faker->email,//生成邮箱 ‘role_id‘ => rand(1, 6), ‘created_at‘ => date(‘Y-m-d H:i:s‘), ‘status‘ => rand(0, 1), ]; $data[] = $line; } DB::table(‘manager‘)->insert($data); } }
标签:laravel框架 tps pass laravel created extend bsp 示例 mail
原文地址:https://www.cnblogs.com/jxl1996/p/10269138.html