php artisan 更新,Laravel 5:PHP Artisan迁移:刷新

我在laravel项目上工作,每次更改表(添加或删除列)并运行php artisan migrate:refresh时.我收到此错误:

[Symfony\Component\Debug\Exception\FatalErrorException] Can’t use

method return value in write context

解决方案尝试:

>运行composer dump-autoload(失败)

>在数据库中删除表,删除迁移文件,然后再次重新启动(有效)

先前的迁移文件:

use Illuminate\Support\Facades\Schema;

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Database\Migrations\Migration;

class CreateCommentsTable extends Migration

{

/**

* Run the migrations.

*

* @return void

*/

public function up()

{

Schema::create('comments', function (Blueprint $table) {

$table->increments('id');

$table->integer('post_id');

$table->string('body');

$table->timestamps();

});

}

/**

* Reverse the migrations.

*

* @return void

*/

public function down()

{

Schema::dropIfExists('comments');

}

}

更改的迁移文件:

use Illuminate\Support\Facades\Schema;

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Database\Migrations\Migration;

class CreateCommentsTable extends Migration

{

/**

* Run the migrations.

*

* @return void

*/

public function up()

{

Schema::create('comments', function (Blueprint $table) {

$table->increments('id');

$table->integer('user_id');

$table->integer('post_id');

$table->string('body');

$table->timestamps();

});

}

/**

* Reverse the migrations.

*

* @return void

*/

public function down()

{

Schema::dropIfExists('comments');

}

}

我在up函数的更改文件中添加了user_id

解决方法:

试试这个命令对我有用

php artisan migrate:fresh

标签:laravel-5-5,laravel-5,php

来源: https://codeday.me/bug/20191111/2022128.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值