迁移

时间:2017-09-12 07:07:24

标签: php laravel

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSubcategoryTable extends Migration
{
    public function up()
    {``
        Schema::create('subcategories', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('description');
            $table->string('parent');
            $table->timestamps();
        });
    }


    public function down()
    {
        Schema::dropIfExists('subcategories');
    }
}

这是我的代码但是在迁移时问题显示

  

类Illuminate \ Database \ Schema \ Blueprint的对象无法转换为字符串

2 个答案:

答案 0 :(得分:0)

public function up()
{Schema::dropIfExists('subcategories');

答案 1 :(得分:0)

<块引用>

您的代码有错误,就像您输入了额外的逗号一样 在公共函数 up(){ ``

之后
 <?php

 use Illuminate\Support\Facades\Schema;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;

 class CreateSubcategoryTable extends Migration
 {
   public function up()
   {``
    Schema::create('subcategories', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('description');
        $table->string('parent');
        $table->timestamps();
    });
}


public function down()
{
    Schema::dropIfExists('subcategories');
}

}