1. Go to this page and download the library: Download lingyun/think-migration library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use think\migration\Seeder;
class UserSeeder extends Seeder
{
public function run()
{
$this->factory()->create(User::class); //使用工厂类填充1条数据
$this->factory()->of(User::class)->times(2)->create(); //使用工厂类填充2条数据
$this->factory()->of(User::class, 'example')->create();
}
}
php think factory:create User
use Faker\Generator as Faker;
use think\migration\Factory;
/** @var Factory $factory */
$factory->state(\app\model\User::class, 'unverified', ['email_verified_at' => null]);
$factory->state(\app\model\User::class, 'unremember', ['remember_token' => null]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.