Generate models for existing database tables - Laravel
To generate / build model files for our existing database tables, first we have to install following package:
Just notice the above command, we are using "--schema", to tell this package, to generate models for this specific database. If you haven't supply that option, it will generate models for all the tables except mysql default databases like "information_schema" etc.,
You can find more options like generating model for specific table etc, in the following link:
https://github.com/laracademy/generators
composer require "laracademy/generators" --devOnce the above step gets complete, please run below command inside your project root directory:
php artisan generate:modelfromtable --schema="YOUR_DATABASE_NAME"
Just notice the above command, we are using "--schema", to tell this package, to generate models for this specific database. If you haven't supply that option, it will generate models for all the tables except mysql default databases like "information_schema" etc.,
You can find more options like generating model for specific table etc, in the following link:
https://github.com/laracademy/generators
Comments (0)