承接 pursehouse/modeler-laravel-eloquent 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pursehouse/modeler-laravel-eloquent

最新稳定版本:v0.1.0

Composer 安装命令:

composer require pursehouse/modeler-laravel-eloquent

包简介

Generate model classes for Eloquent in Laravel

README 文档

README

StyleCI Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Generate model classes for Eloquent in Laravel

How does it work?

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

composer config repositories.pursehouse/modeler-laravel-eloquent vcs https://github.com/pursehouse/modeler-laravel-eloquent

composer require pursehouse/modeler-laravel-eloquent:dev-master

Configuration

Add the service provider to your config/app.php file within the providers key:

// ...
'providers' => [
    /*
     * Package Service Providers...
     */

    Pursehouse\Modeler\Coders\CodersServiceProvider::class,
],
// ...

Configuration for local environment only

If you wish to enable generators only for your local environment, you should install it via composer using the --dev option like this:

composer config repositories.pursehouse/modeler-laravel-eloquent vcs https://github.com/pursehouse/modeler-laravel-eloquent

composer require pursehouse/modeler-laravel-eloquent:dev-master --dev

Then you'll need to register the provider in app/Providers/AppServiceProvider.php file.

public function register()
{
    if ($this->app->environment() == 'local') {
        $this->app->register(\Pursehouse\Modeler\Coders\CodersServiceProvider::class);
    }
}

Models

Generating models with artisan

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

php artisan vendor:publish --tag=pursehouse-modeler
php artisan config:clear

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 pursehouse:modeler
  • You can scaffold a specific table like this:
php artisan pursehouse:modeler --table=users
  • You can also specify the connection:
php artisan pursehouse:modeler --connection=mysql
  • If you are using a MySQL database, you can specify which schema you want to scaffold:
php artisan pursehouse:modeler --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 you 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 :-)

Origins

Originally forked from Reliese/larvel project

统计信息

  • 总下载量: 2.35k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 0
  • Forks: 325
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-26