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

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

This question already has an answer here:

I have created migration file in that i have written :

  1. public function up()
  2. {
  3. //
  4. Schema::create('ad_group', function (Blueprint $table) {
  5. $table->increments('id');
  6. $table->integer('campaign_id')->unsigned();
  7. $table->char('name',32);
  8. });
  9. Schema::table('ad_group',function (Blueprint $table){
  10. $table->foreign('campaign_id')->references->('id')->on('campaigns');
  11. });
  12. }

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-09 22:17
    关注
    1. Your mistake is "->references->('id')->" must be "->references('id')->"
    2. public function up() {
    3. Schema::table('ad_group', function (Blueprint $table) {
    4. $table->foreign('campaign_id')->references('id')->on('campaigns');
    5. });
    6. }

    Hope it help :)

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部