Since model factories create in-memory objects, because of big memory usages it is not suitable for large seeds.

But you can use Faker for data generation:

use Faker\Generator as Faker;
class PostSeeder extends Seeder
{
    public function run(Faker $faker)
    {
        $users= collect(User::all()->modelKeys());
        $data = [];

        for (i < 100000; $i++) {
            $data[] = [
                'body' => $faker->text,
                'image' => $faker->imageUrl(),
                'user_id' => $users->random(),
                'created_at' => now()->toDateTimeString(),
                'updated_at' => now()->toDateTimeString(),
            ];
        }

        $chunks = array_chunk($data, 10000);

        foreach ($chunks as $chunk) {
            Post::insert($chunk);
        }
    }
}
Answer from Mohsen Nazari on Stack Overflow
🌐
GitHub
github.com › fzaninotto › Faker
GitHub - fzaninotto/Faker: Faker is a PHP library that generates fake data for you · GitHub
pattern-lab/plugin-faker: Pattern Lab is a Styleguide, Component Library, and Prototyping tool. This creates unique content each time Pattern Lab is generated. guidocella/eloquent-populator: Adapter for Laravel's Eloquent ORM.
Starred by 26.7K users
Forked by 3.6K users
Languages   PHP
🌐
FakerPHP
fakerphp.org
FakerPHP / Faker
Faker is a PHP library that generates fake data for you.
🌐
Welcm Learning
welcm.uk › blog › getting-started-with-faker-in-laravel
Getting Started With Faker in Laravel | Welcm Learning. Blog
A look at the functions of the Faker PHP library and how to set up Model Factories and Seeders for your Laravel application
🌐
Laravel
laravel.com › docs › 7.x › database-testing
Database Testing | Laravel 7.x - The clean stack for Artisans and agents
Instead of manually specifying the value of each column when you create this test data, Laravel allows you to define a default set of attributes for each of your Eloquent models using model factories. To get started, take a look at the database/factories/UserFactory.php file in your application. Out of the box, this file contains one factory definition: ... use Faker\Generator as Faker; use Illuminate\Support\Str; $factory->define(App\User::class, function (Faker $faker) { return [ 'name' => $faker->name, 'email' => $faker->unique()->safeEmail, 'email_verified_at' => now(), 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 'remember_token' => Str::random(10), ]; });
🌐
Shortcode
shortcode.dev › laravel › faker.html
Laravel cheatsheet > Faker
$faker = Faker\Factory::create(); $faker->name; // First and second name $faker->randomDigit; // A random number $faker->word; // A single word $faker->sentence; // A sentence $faker->unique()->word; // A single unique word $faker->text($maxNbChars = 300); // 300 character long text $faker->safeEmail; // An email address $faker->hexcolor; // Hex color copy
🌐
InterServer
interserver.net › home › mastering realistic data generation in laravel with faker: a comprehensive guide
Mastering Realistic Data Generation in Laravel with Faker: A Comprehensive Guide - Interserver Tips
January 28, 2024 - Open the LocationsTableSeeder file and add the following code. public function run() { $faker = Faker::create(); foreach (\App\Models\User::all() as $user) { $user->locations()->create([ 'address' => $faker->address, 'latitude' => $faker->latitude, 'longitude' => $faker->longitude, ]); } } After adding the code, execute the seeder file using the following command. ... Completing the above steps adds realistic location data that helps you attach a realistic touch to your testing environment. It might be possible that you cover users all over the world; in that case, you need to test how your system handles data in various languages. Laravel Faker simplifies this process by supporting localization, enabling the generation of data specific to different regions.
🌐
GitHub
github.com › mbezhanov › laravel-faker-provider-collection
GitHub - mbezhanov/laravel-faker-provider-collection: A collection of custom Faker providers for your Laravel applications
A collection of custom Faker providers for your Laravel applications - mbezhanov/laravel-faker-provider-collection
Starred by 21 users
Forked by 6 users
Languages   PHP 100.0% | PHP 100.0%
Find elsewhere
🌐
Sven Hofmann
hofmannsven.com › 2021 › faker-provider-in-laravel
How to implement a custom Faker Provider in Laravel | Sven Hofmann
March 24, 2021 - Next, register the class in Laravel. You can generate a new Laravel service provider via the artisan command: ... use App\Faker\FrameworkProvider; use Faker\{Factory, Generator}; use Illuminate\Support\ServiceProvider;
🌐
Laravel News
laravel-news.com › home › laravel packages › laravel faker openai
Laravel Faker OpenAI - Laravel News
January 23, 2025 - An opinionated Laravel package that extends FakerPHP and uses openai-php/laravel to generate fake data
🌐
AlexHost
alexhost.com › home › faq › mastering realistic data generation in laravel with faker: a comprehensive guide
Mastering Realistic Data Generation in Laravel with Faker: A Comprehensive Guide
September 30, 2025 - Faker is a powerful PHP library that generates fake, but realistic, data for testing and seeding databases. In Laravel, Faker is integrated with Eloquent model factories, making it easy to create models with random data for development, testing, ...
🌐
Gdebrauwer
gdebrauwer.dev › blog › how-to-customize-php-faker-in-laravel
How to customize PHP Faker in Laravel | Günther Debrauwer
August 19, 2023 - A tutorial on how to customize Laravel's Faker instance by adding custom (chainable) methods.
🌐
Laravel Daily
laraveldaily.com › tip › use-faker-outside-factories-or-seeders
Use faker outside factories or seeders
If you want to generate some fake data, you can use Faker even outside factories or seeds, in any class.
🌐
Shivlab
shivlab.com › home › how to use laravel faker for random date generation
How to Use Laravel Faker for Random Date Generation
September 5, 2024 - In this guide, I will walk you through the steps to integrate and use Faker to generate random dates in a Laravel project.
🌐
Laravel
laravel.com › docs › 12.x › eloquent-factories
Eloquent: Factories | Laravel 12.x - The clean stack for Artisans and agents
As you can see, in their most basic form, factories are classes that extend Laravel's base factory class and define a definition method. The definition method returns the default set of attribute values that should be applied when creating a model using the factory. Via the fake helper, factories have access to the Faker PHP library, which allows you to conveniently generate various kinds of random data for testing and seeding.
🌐
Laravel.io
laravel.io › forum › how-to-create-factory-for-product-and-categories
How to create factory for Product and Categories? | Laravel.io
I think you can use a custom provider if you want to have a custom options for your product and category names: https://fakerphp.github.io/#faker-internals-understanding-providers ... Sign in to participate in this thread! ... The Laravel portal for problem solving, knowledge sharing and community building.