0 && Plan::count() > 0) { $comments = PlanComment::factory()->count(5)->make(); $comments->each(function ($comment) { $comment->author()->associate( User::inRandomOrder() ->first() ->id ); $comment->plan()->associate( Plan::inRandomOrder() ->first() ->id ); $comment->saveOrFail(); }); } } }