我已经创建了迁移文件,我写了:
public function up()
{
//
Schema::create('ad_group', function (Blueprint $table) {
$table->increments('id');
$table->integer('campaign_id')->unsigned();
$table->char('name',32);
});
Schema::table('ad_group',function (Blueprint $table){
$table->foreign('campaign_id')->references->('id')->on('campaigns');
});
}
返回如下错误:
[Symfony的\元器件\调试\异常\ FatalThrowableError]
解析错误:语法错误,意外'(',期望标识符(T_STRING)或变量(T_VARIABLE)或'{'或'$'
答案 0 :(得分:0)
Your mistake is "->references->('id')->" must be "->references('id')->"
public function up() {
Schema::table('ad_group', function (Blueprint $table) {
$table->foreign('campaign_id')->references('id')->on('campaigns');
});
}
希望有所帮助:)