seeder.stub 557 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?php

declare(strict_types=1);

use App\Model\%modelClass%;%otherModel%
use Faker\Factory;
use Hyperf\Database\Seeders\Seeder;
use Hyperf\DbConnection\Db;

class %className% extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $faker = Factory::create('zh-CN');
王源's avatar
王源 committed
20
        %modelClass%::query()->truncate();
21 22 23 24 25 26 27 28 29
        $n = %generateCount%;
        for ($i = 0; $i < $n; $i++) {
            $instance = %modelClass%::create([
%fields%
            ]);
%otherProcess%
        }
    }
}