coderello/laravel-populated-factory
最新稳定版本:1.1.0
Composer 安装命令:
composer require coderello/laravel-populated-factory
包简介
An easy way to generate populated factories.
README 文档
README
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:
composer require --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 the
Usermodel is in theAppnamespace. If your models are situated in another namespace (e.g.App\Models) you should specify them either asModels\\Useror\\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
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 23k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 245
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-07