【发布时间】:2013-12-21 08:48:18
【问题描述】:
我是 Laravel PHP 框架的新手。我对 Laravel 模式构建器和迁移的工作方式感到困惑。我使用 Laravel 迁移创建了两个表。下面是我的两张表:
public function up()
{
Schema::create('hotels', function(Blueprint $table)
{
$table->increments('id');
$table->integer('hotel_id');
$table->string('name');
$table->string('address')->nullable();
$table->string('city')->nullable();
$table->string('province')->nullable();
$table->string('country')->nullable();
$table->timestamps();
});
}
这是我的另一张桌子:
public function up()
{
Schema::create('rooms', function(Blueprint $table)
{
$table->increments('id');
$table->integer('hotel_id');
$table->string('name');
$table->timestamps();
});
}
我的问题是如何使用外键与两个表建立关系?如果我必须使用 Schema Builder,我必须将模式文件放在哪里?
【问题讨论】: