0

Laravel 主动生成 Model 通过三方包 ignasbernotas/laravel-model-generator

neo created at6 years ago view count: 2991

Laravel 通过第三方包直接从数据库的Table schema 生成Model。 可以节约很多时间.

地址:https://github.com/ignasbernotas/laravel-model-generator

安装

  1. composer require ignasbernotas/laravel-model-generator --dev
  2. app/Providers/AppServiceProvider.php 新加下面内容
<?php

public function register()
{
    if ($this->app->environment() == 'local') {
        $this->app->register('Iber\Generator\ModelGeneratorProvider');
    }
}

使用

php artisan make:models

其他参数

php artisan help make:models

Usage:
  make:models [options]

Options:
      --tables[=TABLES]          Comma separated table names to generate
      --prefix[=PREFIX]          Table Prefix [default: DB::getTablePrefix()]
      --dir[=DIR]                指定Model生成的目录。Model directory [default: "Models/"]
      --extends[=EXTENDS]        设置继承的类。Parent class [default: "Illuminate\Database\Eloquent\Model"]
      --fillable[=FILLABLE]      Rules for $fillable array columns [default: ""]
      --guarded[=GUARDED]        Rules for $guarded array columns [default: "ends:_guarded"]
      --timestamps[=TIMESTAMPS]  Rules for $timestamps columns [default: "ends:_at"]
  -i, --ignore[=IGNORE]          Ignores the tables you define, separated with ,
  -f, --force[=FORCE]            Force override [default: false]
  -s, --ignoresystem             If you want to ignore system tables.
                                              Just type --ignoresystem or -s
  -m, --getset                   Defines if you want to generate set and get methods
  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --env[=ENV]                The environment the command should run under.
report
回复
0

这个已经没有更新不能用了, 项目维护的人推荐使用 https://github.com/reliese/laravel 代替。

6 years ago 回复

Recent search keywords