faker = Factory::create(); } /** * Create new comments. * * @return \Tightenco\Collect\Support\Collection */ public function create(): Collection { $talkTitle = $this->faker->sentence; return tap(collect(), function (Collection $data) use ($talkTitle) { if ($this->commentCount > 0) { foreach (range(1, $this->commentCount) as $i) { $comment = new \stdClass(); $comment->talk_title = $talkTitle; $comment->comment = $this->faker->paragraph; $comment->uri = 'http://api.joind.in/v2.1/talk_comments/' . $this->faker->randomNumber(8); $comment->user_display_name = $this->faker->name; $data->push($comment); } } }); } /** * Set the number of comments to create. * * @param int $count * * @return \App\Tests\Helpers\Factory\CommentFactory */ public function setCount(int $count): self { $this->commentCount = $count; return $this; } }