dqwp81696 2017-05-10 05:35
浏览 30
已采纳

外键在laravel 5.4中显示语法错误[重复]

This question already has an answer here:

I have created migration file in that i have written :

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');
        });
    }

which returns error like this :

[Symfony\Component\Debug\Exception\FatalThrowableError]
Parse error: syntax error, unexpected '(', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$'

</div>
  • 写回答

1条回答 默认 最新

  • douyou4819 2017-05-10 06:17
    关注
    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');
        });
    }
    

    Hope it help :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?