modelgen is a command that will quickly generate a model for you based on your current table scheme found in your database.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
README.md
composer.json

README.md

Model Generator

Latest Stable Version Total Downloads Latest Unstable Version License

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):

Requirements

  1. PHP 5.6+
  2. Laravel 5.2+

Usage

Step 1: Install through Composer

composer require "laracademy/model-generator"

Step 2: Add the Service Provider

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');
    }
}

Artisan

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

Examples

Generating a single table

php artisan generate:model --table=users

Generating a multiple tables

php artisan generate:model --table=users,posts

Generating all tables

php artisan generate:model --all

Changing to another connection found in database.php and generating models for all tables

php artisan generate:model --connection=spark --all

License

ModelGen is open-sourced software licensed under the MIT license

Bug Reporting and Feature Requests

Please add as many details as possible regarding submission of issues and feature requests

Disclaimer

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.