コード例 #1
0
ファイル: DevSeeder.php プロジェクト: gez-studio/gez-mall
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     /*
     |--------------------------------------------------------------------------
     | Create dummy users
     |--------------------------------------------------------------------------
     */
     factory(User::class, 'verified', 20)->create();
     /*
     |--------------------------------------------------------------------------
     | Init sellers and create shops
     |--------------------------------------------------------------------------
     */
     $users = User::all();
     foreach ($users as $user) {
         if ($this->faker->boolean(50)) {
             $this->initSeller($user);
         }
     }
     foreach (getTestAccounts() as $testAccount) {
         $testUser = User::where('email', $testAccount['email'])->first();
         if (!$testUser->isShopOwner()) {
             $this->initSeller($testUser);
         }
     }
     /*
     |--------------------------------------------------------------------------
     | Seed common data for users and shops
     |--------------------------------------------------------------------------
     */
     // select 80% of users and assign 1 to 3 addresses
     foreach ($users as $user) {
         $this->seedCommonData($user);
     }
     $shops = Shop::all();
     // select 80% of sellers and assign 1 to 3 address
     foreach ($shops as $shop) {
         $this->seedCommonData($shop);
     }
     /*
     |--------------------------------------------------------------------------
     | Seed seller data for users and shops
     |--------------------------------------------------------------------------
     */
     foreach ($shops as $shop) {
         if ($this->faker->boolean(80)) {
             $this->seedSellerData($shop);
         }
     }
     foreach ($users as $user) {
         if ($this->faker->boolean(80)) {
             $this->seedSellerData($user);
         }
     }
     /*
     |--------------------------------------------------------------------------
     | Seed forum data
     |--------------------------------------------------------------------------
     */
     $this->call(\App\Modules\ForumModule\Database\Seeders\TagSeeder::class);
     $this->call(\App\Modules\ForumModule\Database\Seeders\PostSeeder::class);
     $this->call(\App\Modules\ForumModule\Database\Seeders\CommentSeeder::class);
     $this->call(\App\Modules\ForumModule\Database\Seeders\VoteSeeder::class);
 }