创建模型
php artisan make:model Match
<?php
namespace App\Models;
use EloquentFilter\Filterable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Match extends Model
{
    use HasFactory;
    protected $table = 'xxx_match';
    public $timestamps = false;
}
默认情况下,Eloquent 会预计你的数据表中有 created_at 和 updated_at 字段。如果你不希望自动维护这两个字段,可在模型内将 $timestamps 属性设置为 false。
创建工厂
php artisan make:factory MatchFactory
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
class MatchFactory extends Factory
{
    protected $mas = ['aaa', 'ccc', 'vvv', 'xxx', 'aaa'];
    protected $users = ['ee', 'ddd', 'bb', 'cc', 'aa'];
    /**
     * Define the model's default state.
     *
     * @return array
     */
    public function definition()
    {
        return [
            'a' => 'C' . rand(1000000,9999999),
            'c' => $this->getRandData($this->mas),
            'v' => (string)rand(100000, 999999),
            'f' => rand(1,2),
            'g' => '',
            'h' => rand(1,4),
            'l' => rand(1,4),
            'b' => $this->getRandData($this->users),
            'm' => $this->getRandData($this->users),
        ];
    }
    protected function getRandData($data)
    {
        return $data[rand(0,4)];
    }
}
创建填充文件
php artisan make:seeder MatchSeeder
<?php
namespace Database\Seeders;
use App\Models\Match;
use Illuminate\Database\Seeder;
class MatchSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Match::factory()->count(20000)->create();
    }
}
填充数据
php artisan db:seed --class=MatchSeeder
	更多精彩内容:各种AI课程、技能课程、黑科技软件、网站小程序源码、副业小项目、PPT模板等精品素材、电商课程、推广引流课程等,尽在 天边资源网 。