Package Data | |
---|---|
Maintainer Username: | coderello |
Package Create Date: | 2019-03-07 |
Package Last Update: | 2020-11-18 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-15 15:23:08 |
Package Statistics | |
---|---|
Total Downloads: | 22,893 |
Monthly Downloads: | 15 |
Daily Downloads: | 0 |
Total Stars: | 249 |
Total Watchers: | 6 |
Total Forks: | 17 |
Total Open Issues: | 0 |
You can install this package via composer using this command:
composer require --dev coderello/laravel-populated-factory
The package will automatically register itself.
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 the
User
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 the User
model according to its column types & names.
<?php
use Faker\Generator as Faker;
/** @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
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.