示例#1
0
 public function createUsersWithAsocs($count)
 {
     for ($i = 1; $i <= $count; $i++) {
         $user = User::create(['login' => 'login_' . $i, 'password' => 'password_' . $i, 'email' => 'email_' . $i . '@example.com']);
         $profile = Profile::create(['userId' => $user->id, 'sign' => 'signature of user ' . $user->id]);
         for ($j = 1; $j <= $count; $j++) {
             $relation = UserAndGroupRelation::create(['userId' => $user->id, 'groupId' => $j]);
             $post = BlogPost::create(['userId' => $user->id, 'title' => "Post {$i}", 'message' => "This is a message {$i}!", 'createdAt' => time() + $i]);
             for ($k = 1; $k <= $count; $k++) {
                 $comment = BlogComment::create(['userId' => $user->id, 'blogPostId' => $post->id, 'title' => "Comment {$j} to post {$i}", 'message' => "This is a comment message {$i}:{$j}!", 'createdAt' => time() + $j]);
             }
         }
     }
 }
示例#2
0
 public function createPostsWithComments($postsCount, $commentsCount)
 {
     $userId = 2;
     for ($i = 1; $i <= $postsCount; $i++) {
         $post = BlogPost::create(['userId' => $userId, 'title' => "Post {$i}", 'message' => "This is a message {$i}!", 'createdAt' => time() + $i]);
         for ($j = 1; $j <= $commentsCount; $j++) {
             $comment = BlogComment::create(['userId' => $userId, 'blogPostId' => $post->id, 'title' => "Comment {$j} to post {$i}", 'message' => "This is a comment message {$i}:{$j}!", 'createdAt' => time() + $j]);
         }
     }
 }