LaravelPackages.net
Acme Inc.
Toggle sidebar
webikevn/laravel-generate-factory

141
1
1.0.5
About webikevn/laravel-generate-factory

webikevn/laravel-generate-factory is a Laravel package. It currently has 1 GitHub stars and 141 downloads on Packagist (latest version 1.0.5). Install it with composer require webikevn/laravel-generate-factory. Discover more Laravel packages by webikevn or browse all Laravel packages to compare alternatives.

Last updated

Generate Laravel Factory Templates

Make Laravel factory file with the column names of a table in a database.

screenshot

Installing

composer require --dev webikevn/laravel-generate-factory

If you are using Laravel 5.5 or higher, the package will be automatically registered.

Configuration

Optionally, you can publish the config file by running this command.

php artisan vendor:publish --provider="Webike\Factory\FactoryGeneratorServiceProvider"

And then, you can find config\factory-generator.php.

<?php

return [
    
    /**
     * Set the namespace of the model.
     */
    'namespace' => [
        'model' => 'App',
    ],

    /**
     * List of the columns that will not appear in the factory.
     */
    'ignored_columns' => [
        'id',
    ],
];

Usage

After installing and Configuration, you can generate the factory file by running the following command.

Please pass the table name to generate:factory command as the argument.

php artisan generate:factory some_samples

NOTE This command connects to the database to retrieve the columns from table, so make sure that the database is configured.

To generate factories of all tables in database.

Use --all option without table name, to generate factories of all tables in database.

If a factory of table exists, it will be skipped and continue to generate factories of other tables.

php artisan generate:factory  --all

License

This project is released under MIT License. See MIT License for the detail.

Star History Chart