Fillable Generator is a Laravel package that simplifies the process of generating fillable arrays for Eloquent models based on migration files.
You can install the Fillable Generator package via Composer. Run the following command in your Laravel project directory:
composer require vishnu/fillable-generator
To generate fillable arrays for your models, use the fillable:g
Artisan command provided by the Fillable Generator package.
php artisan fillable:g
Follow the on-screen prompts to enter the path to your migration file and the name of the corresponding model. The command will parse the migration file, extract the column names, and generate a fillable array for the specified model.
Let's walk through an example of using the Fillable Generator package:
-
Suppose you have a migration file named
create_users_table.php
located in thedatabase/migrations
directory. -
Run the
fillable:g
command and enter the path to the migration file when prompted:php artisan fillable:g
Example prompt:
Enter the migration file path (e.g., database/migrations/2024_04_07_183244_create_users_table.php):
-
Next, enter the name of the corresponding model (e.g.,
User
):Enter the model name (e.g., User):
-
The command will generate a fillable array for the
User
model based on the columns defined in the migration file and update the model file accordingly.
If you encounter any issues or have questions about using the Fillable Generator package, please open an issue on GitHub.
The Fillable Generator package is open-source software licensed under the MIT license.