Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 尝试使用Faker和TestDummy进行播种以提高效率_Php_Laravel_Laravel 5 - Fatal编程技术网

Php 尝试使用Faker和TestDummy进行播种以提高效率

Php 尝试使用Faker和TestDummy进行播种以提高效率,php,laravel,laravel-5,Php,Laravel,Laravel 5,我想知道我是否需要重新考虑如何用播种机播种我所有的桌子。是否有更好更有效的方法来处理所有这些数据。出于某种原因运行种子类之后,我总共有202个用户。一个是me,然后是201个虚拟用户,但应该只有200个虚拟用户。我不知道额外的用户是从哪里来的 目标: 仅为我创建一个用户帐户,并为每个帐户提供值 用户表中的字段 使用虚拟数据在数据库中创建200个附加用途 测试假人和冒牌货 为我自己和其他每个用户创建一行,以便 为用户配置文件中的每个字段提供值的配置文件 桌子 为我自己和其他每个用户创建一行链接 为

我想知道我是否需要重新考虑如何用播种机播种我所有的桌子。是否有更好更有效的方法来处理所有这些数据。出于某种原因运行种子类之后,我总共有202个用户。一个是me,然后是201个虚拟用户,但应该只有200个虚拟用户。我不知道额外的用户是从哪里来的

目标:

  • 仅为我创建一个用户帐户,并为每个帐户提供值 用户表中的字段
  • 使用虚拟数据在数据库中创建200个附加用途 测试假人和冒牌货
  • 为我自己和其他每个用户创建一行,以便 为用户配置文件中的每个字段提供值的配置文件 桌子
  • 为我自己和其他每个用户创建一行链接 为中的每个字段提供值的社交网络页面 用户配置文件社交链接表
  • 我的代码文件

    <?php
    
    use Illuminate\Database\Seeder;
    
    use Laracasts\TestDummy\Factory as TestDummy;
    use App\User;
    
    class UsersTableSeeder extends Seeder {
    
        public function run()
        {
            User::create([
                'first_name' => 'Secret',
                'last_name' => 'Secret',
                'username' => 'secret',
                'email' => 'secret@gmail.com',
                'password' => 'secret',
            ]);
    
            TestDummy::times(200)->create('App\User');
        }
    
    }
    
    <?php
    
    use Illuminate\Database\Seeder;
    
    use Laracasts\TestDummy\Factory as TestDummy;
    use App\UserProfile;
    
    class UserProfilesTableSeeder extends Seeder {
    
        public function run()
        {
            UserProfile::create([
                'user_id' => '1',
                'avatar' => NULL
                'bio' => 'This is just my personal biography!',
                'address' => NULL
                'city' => NULL
                'state' => NULL
                'postcode' => NULL
                'country' => NULL
                'phone' => NULL
                'birthday' => NULL
            ]);
    
            TestDummy::create('App\UserProfile');
        }
    
    }
    
    <?php
    
    use Illuminate\Database\Seeder;
    
    use Laracasts\TestDummy\Factory as TestDummy;
    use App\UserProfileSocialLinks;
    
    class UserProfileSocialLinksTableSeeder extends Seeder {
    
        public function run()
        {
            UserProfileSocialLinks::create([
                'user_id' => '1',
                'facebook_username' => NULL
                'twitter_username' => NULL
                'google_username' => NULL,
                'behance_username' => NULL,
                'pinterest_username' => NULL,
                'linkedin_username' => NULL
                'github_username' => NULL
                'youtube_username' => NULL
                'instagram_username' => NULL
                'external_link' => NULL
            ]);
    
            //TestDummy::create('App\UserProfileSocialLinks');
        }
    
    }
    
    <?php
    
    $factory('App\User', [
        'first_name' => $faker->firstName,
        'last_name' => $faker->lastName,
        'username' => $faker->userName,
        'email' => $faker->email,
        'password' => $faker->word
    ]);
    
    $factory('App\UserProfile', [
        'user_id' => 'factory:App\User',
        'bio' => $faker->sentence(100),
        'avatar' => $faker->imageUrl($width = 640, $height = 480),
        'address' => $faker->optional($weight = 0.9)->address,
        'city' => $faker->optional($weight = 0.9)->city,
        'state' => $faker->optional($weight = 0.9)->state,
        'postcode' => $faker->optional($weight = 0.9)->postcode,
        'country' => $faker->optional($weight = 0.9)->country,
        'phone' => $faker->optional($weight = 0.9)->phoneNumber,
        'birthday' => $faker->optional($weight = 0.9)->dateTimeBetween('-40 years', '-18 years')
    ]);
    
    $factory('App\UserProfileSocialLinks', [
        'user_id' => 'factory:App\UserProfile',
        'facebook_username' => $faker->optional($weight = 0.9)->userName,
        'twitter_username' => $faker->optional($weight = 0.9)->userName,
        'google_username' => $faker->optional($weight = 0.9)->userName,
        'behance_username' => $faker->optional($weight = 0.9)->userName,
        'pinterest_username' => $faker->optional($weight = 0.9)->userName,
        'linkedin_username' => $faker->optional($weight = 0.9)->userName,
        'github_username' => $faker->optional($weight = 0.9)->userName,
        'youtube_username' => $faker->optional($weight = 0.9)->userName,
        'instagram_username' => $faker->optional($weight = 0.9)->userName
    ]);