PHP code example of yunbuye / thinkphp-model-factory

1. Go to this page and download the library: Download yunbuye/thinkphp-model-factory 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/ */

    

yunbuye / thinkphp-model-factory example snippets


        use Faker\Generator as Faker;
        
        $factory->define(App\User::class, function (Faker $faker) {
            return [
                'name' => $faker->name,
                'email' => $faker->unique()->safeEmail,
                'email_verified_at' => now(),
                'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
                'remember_token' => Str::random(10),
            ];
        });
        

        public function testDatabase()
        {
            $user = factory(App\User::class)->make();
            
            // 在测试中使用模型...
        }