我正在做一个laravel项目,每次更改表(添加或删除列)并运行php artisan migrate:refresh。我收到此错误:
[Symfony \ Component \ Debug \ Exception \ FatalErrorException]无法在写上下文中使用方法返回值
解决方案尝试:
composer dump-autoload(失败)先前的迁移文件:
<?php
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');
}
}
Run Code Online (Sandbox Code Playgroud)
更改的迁移文件:
<?php
use Illuminate\Support\Facades\Schema;
use …Run Code Online (Sandbox Code Playgroud)