2017 © Pedro PelĂĄez
 

library laravel-models-generator

Eloquent model generation from the database.

image

axn/laravel-models-generator

Eloquent model generation from the database.

  • Wednesday, July 4, 2018
  • by axn
  • Repository
  • 2 Watchers
  • 0 Stars
  • 366 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 16 Versions
  • 11 % Grown

The README.md

Laravel Models Generator

Generates Eloquent models and relations (belongs to, has many, has one) using DB schema., (*1)

Installation

Install the package with Composer:, (*2)

composer require axn/laravel-models-generator

In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just add the service provider to the array of providers in config/app.php:, (*3)

'providers' => [
    // ...
    Axn\ModelsGenerator\ServiceProvider::class,
],

Publish config and templates (stubs) if needed using these commands:, (*4)

// config
php artisan vendor:publish --tag=models-generator.config

// stubs
php artisan vendor:publish --tag=models-generator.stubs

Config is published in config/models-generator.php Templates are published in resources/stubs/vendor/models-generator/, (*5)

Modify config options and templates contents if needed., (*6)

Usage

Simply launch this command:, (*7)

php artisan models:generate

Options :, (*8)

  • --table (ou -t) : if you want to generate only certain tables. To select many tables, you can do: -t table1 -t table2 -t ...
  • --preview (ou -p) : if you want to only display information messages about actions that will be done by the generator but without touching files.

Naming convention

  • Model: table name in singular and studly case (cf config "singular_rules" if singularization is not done correctly).
  • "has many" relation: name of the related table (plural), in camel case.
  • "has one" relation: name of the related table (singular), in camel case
  • "belongs to" relation: foreign key name (without "_id" or "id_"), in camel case.

Other details:, (*9)

  • "has many" relation: the relation name is simply the model name in camel case, so the model name should be in plural.
  • "has many" and "has one" relations: if the foreign key name is not standard, a precision is concatenated to the relation name like "Via{nomFK}".

Example:, (*10)

// "comments" table
class Comment extends Model
{
    // "belongs to" relation to "users" via "user_id"
    public function user() {}

    // "belongs to" relation to "users" via "updator_id"
    public function updator() {}
}

// "users" table
class User extends Model
{
    // "has many" relation to "comments" via "user_id"
    public function comments() {}

    // "has many" relation to "comments" via "updator_id"
    public function commentsViaUpdatorId() {}
}

The Versions

04/07 2018

dev-master

9999999-dev https://github.com/AXN-Informatique/laravel-models-generator

Eloquent model generation from the database.

  Sources   Download

MIT

The Requires

 

by AXN Informatique

04/07 2018

5.1.0

5.1.0.0 https://github.com/AXN-Informatique/laravel-models-generator

Eloquent model generation from the database.

  Sources   Download

MIT

The Requires

 

by AXN Informatique

05/06 2018

5.0.0

5.0.0.0 https://github.com/AXN-Informatique/laravel-models-generator

Eloquent model generation from the database.

  Sources   Download

MIT

The Requires

 

by AXN Informatique

18/01 2018

4.1.0

4.1.0.0 https://github.com/AXN-Informatique/laravel-models-generator

Eloquent model generation from the database.

  Sources   Download

MIT

The Requires

 

by AXN Informatique

27/11 2017

4.0.0

4.0.0.0 https://github.com/AXN-Informatique/laravel-models-generator

Eloquent model generation from the database.

  Sources   Download

MIT

The Requires

 

by AXN Informatique

01/02 2017

3.1.0

3.1.0.0 https://github.com/AXN-Informatique/laravel-models-generator

Eloquent model generation from the database.

  Sources   Download

MIT

The Requires

 

by AXN Informatique

02/11 2016

3.0.1

3.0.1.0 https://github.com/AXN-Informatique/laravel-models-generator

Eloquent model generation from the database.

  Sources   Download

MIT

The Requires

 

by AXN Informatique

13/05 2016

3.0.0

3.0.0.0 https://bitbucket.org/axn/laravel-models-generator

Génération des modÚles Eloquent à partir de la base de données.

  Sources   Download

MIT

The Requires

 

by AXN Informatique

22/03 2016

2.0.3

2.0.3.0 https://bitbucket.org/axn/laravel-models-generator

Génération des modÚles Eloquent à partir de la base de données.

  Sources   Download

MIT

The Requires

 

by AXN Informatique

14/01 2016

2.0.2

2.0.2.0

  Sources   Download

The Requires

 

04/01 2016

2.0.1

2.0.1.0

  Sources   Download

The Requires

 

23/12 2015

2.0.0

2.0.0.0

  Sources   Download

The Requires

 

23/11 2015

1.1.1

1.1.1.0

  Sources   Download

The Requires

 

26/10 2015

1.1.0

1.1.0.0

  Sources   Download

The Requires

 

07/10 2015

1.0.1

1.0.1.0

  Sources   Download

The Requires

 

08/09 2015

1.0.0

1.0.0.0

  Sources   Download

The Requires