PLEASE NOTE THAT THIS PACKAGE IS NOW MOVED INTO https://packagist.org/packages/laracademy/generators
Model Generator - Will read your current table structure and generate a model will the filled in fields automatically.
You can generate a single table model, or multiple at once.
Author(s):
- PHP 5.6+
- Laravel 5.2+
composer require "laracademy/model-generator"
The easiest method is to add the following into your config/app.php
file
Laracademy\ModelGenerator\ModelGeneratorServiceProvider::class
Depending on your set up you may want to only use these providers for development, so you don't update your production
servers. Instead, add the provider in `app/Providers/AppServiceProvider.php' like so
public function register()
{
if($this->app->environment() == 'local') {
$this->app->register('\Laracademy\ModelGenerator\ModelGeneratorServiceProvider');
}
}
Now that we have added the generator to our project the last thing to do is run Laravel's Arisan command
php artisan
You will see the following in the list
generate:model
The command comes with a bunch of different options and they are listed below
- --table=
- this can either be a single table, or a list of tables separated by a comma
- --all
- this will ignore any tables that you have added and generate a full list of tables within your database to generate models for
- please note that this command will only ignore the
migrations
table and no model will be generate for it - --connection=
- --debug
- this shows some more information while running
php artisan generate:model --table=users
php artisan generate:model --table=users,posts
php artisan generate:model --all
php artisan generate:model --connection=spark --all
ModelGen is open-sourced software licensed under the MIT license
Please add as many details as possible regarding submission of issues and feature requests
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.