该软件包最新版本(dev-master)没有提供许可证信息。

dev-master 2014-03-31 12:52 UTC

This package is not auto-updated.

Last update: 2024-09-23 14:44:15 UTC


README

使用此软件包,您可以

  • 生成Eloquent模型文件并将其导出到数据库。
  • 使用流畅的接口编写模型规范
  • 定义模型之间的交叉关系

安装

使用[Composer] (https://getcomposer.org.cn)将软件包安装到您的应用程序中

require {
    "boyhagemann/model": "dev-master"
}

然后在app/config/app.php中添加以下行

...
"Boyhagemann\Model\ModelServiceProvider"
...

示例用法

// Get a fresh ModelBuilder instance
$mb = App::make('ModelBuilder');

// Set the name of the model class
$mb->name('Article');

// Set the database table
$mb->table('news');

// Change the folder where to store this model
$mb->folder('/app/models');
   
// Add columns to the table, each with their own fluent interface
// depending on their type of column.
$mb->string('title')->required();
$mb->text('description')->length(50);
$mb->integer('number_of_views');

// Add relationships, each with their own fluent interface
// depending on their type of relationship.
$mb->hasOne('Category');

自动生成和更新模型

此软件包会检查模型是否已在IoC容器中存在。如果不存在,则将Eloquent模型文件写入磁盘并创建数据库表。在开发过程中,在更改配置后立即更新数据库可能很有用。

$mb->autoGenerate();