Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🏭 An easy way to generate populated factories for models.

License

NotificationsYou must be signed in to change notification settings

coderello/laravel-populated-factory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Populated Factory

Laravel Populated Factory provides an easy way to generate populated factories for models according to types & names of their columns.

Install

You can install this package via composer using this command:

composerrequire --dev coderello/laravel-populated-factory

The package will automatically register itself.

Usage

The only thing you need to do in order to generate a populated factory is to execute this command:

php artisan make:populated-factory User

This command assumes that theUser model is in theApp namespace. If your models are situated in another namespace (e.g.App\Models) you should specify them either asModels\\User or\\App\\Models\\User.

Here is the populated factory generated for theUser model according to its column types & names.

<?phpuseFaker\GeneratorasFaker;/** @var $factory \Illuminate\Database\Eloquent\Factory */$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,    ];});

If you want a custom name for the factory, you need to pass it as the second argument like so:

php artisan make:populated-factory User AdminFactory

If you want to override the existent factory, you need to use--force flag like so:

php artisan make:populated-factory User --force

Contributing

Please seeCONTRIBUTING for details.

License

The MIT License (MIT). Please seeLicense File for more information.

About

🏭 An easy way to generate populated factories for models.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors4

  •  
  •  
  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp