Laravel Populated Factory

Laravel Populated Factory

Laravel Populated Factory provides an easy way to generate factory data for models based on types and database column names.

Using the make:populated-factory command by passing a model name and optional factory name override will create a new factory file based on the model. The command assumes the App namespace, so you must pass the full namespace for models located elsewhere:

php artisan make:populated-factory User

The result is a populated factory file based on your model:

<?php

use Faker\Generator as Faker;

$factory->define(\App\User::class, function (Faker $faker) {
    return [
        'name' => $faker->name,
        'email' => $faker->unique()->safeEmail,
        'email_verified_at' => $faker->dateTime,
        'password' => '$2y$10$uTDnsRa0h7wLppc8/vB9C.YqsrAZwhjCgLWjcmpbndTmyo1k5tbRC',
        'remember_token' => $faker->sha1,
        'created_at' => $faker->dateTime,
        'updated_at' => $faker->dateTime,
    ];
});

You can learn more about this package, get full installation instructions, and view the source code on GitHub at coderello/laravel-populated-factory.

Filed in: News / packages
Laravel News Partners

Laravel Jobs

Senior Full-Stack Developer
Atlanta, GA - (remote) USA ONLY
Curricula
PHP Laravel Developer
London
Investoo
Senior Backend Developer
Australia
Tixel
CTO
Copenhagen
Tjommi
Looking for Senior Full-stack Laravel/React.js Javascript API Developer - Immediate (Full-time)
Remote
ApproveMe // Document Signing

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.