Code Monkey home page Code Monkey logo

laravel-eloquent-generator's Introduction

Reliese Laravel Model Generator

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Reliese Laravel Model Generator aims to speed up the development process of Laravel applications by providing some convenient code-generation capabilities. The tool inspects your database structure, including column names and foreign keys, in order to automatically generate Models that have correctly typed properties, along with any relationships to other Models.

How does it work?

This package expects that you are using Laravel 5.1 or above. You will need to import the reliese/laravel package via composer:

Configuration

It is recommended that this package should only be used on a local environment for security reasons. You should install it via composer using the --dev option like this:

composer require reliese/laravel --dev

Add the models.php configuration file to your config directory and clear the config cache:

php artisan vendor:publish --tag=reliese-models

# Let's refresh our config cache just in case
php artisan config:clear

Models

Generating models with artisan

Usage

Assuming you have already configured your database, you are now all set to go.

  • Let's scaffold some of your models from your default connection.
php artisan code:models
  • You can scaffold a specific table like this:
php artisan code:models --table=users
  • You can also specify the connection:
php artisan code:models --connection=mysql
  • If you are using a MySQL database, you can specify which schema you want to scaffold:
php artisan code:models --schema=shop

Customizing Model Scaffolding

To change the scaffolding behaviour you can make config/models.php configuration file fit your database needs. Check it out ;-)

Tips

1. Keeping model changes

You may want to generate your models as often as you change your database. In order not to lose your own model changes, you should set base_files to true in your config/models.php.

When you enable this feature your models will inherit their base configurations from base models. You should avoid adding code to your base models, since you will lose all changes when they are generated again.

Note: You will end up with two models for the same table and you may think it is a horrible idea to have two classes for the same thing. However, it is up to you to decide whether this approach gives value to your project :-)

Support

For the time being, this package supports MySQL, PostgreSQL and SQLite databases. Support for other databases are encouraged to be added through pull requests.

laravel-eloquent-generator's People

Contributors

cristianllanos avatar coatesap avatar finiteinfinity avatar damienburkejj avatar rwdim avatar boukeversteegh avatar anurbol avatar myusuf5400 avatar timhaak avatar jefhar avatar syclone avatar nhoemchenda avatar nasatome avatar mvd81 avatar jampot5000 avatar alibori avatar antriver avatar bassco avatar 0kyn avatar omranic avatar pozhidaevak avatar delmicio avatar fmrodrigues92 avatar rdewilde avatar fridzema avatar tpaksu avatar acousticksan avatar angujo avatar kl4ver avatar neatstudio avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.