【问题标题】:Laravel: Call to undefined method Illuminate\Database\Schema\Blueprint::create_table ()Laravel:调用未定义的方法 Illuminate\Database\Schema\Blueprint::create_table ()
【发布时间】:2017-07-19 16:14:29
【问题描述】:

我正在学习 Laravel 并使用

迁移数据库表

php 工匠迁移

然后我得到一个错误

[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined method Illuminate\Database\Schema\Blueprint::create_table()

它来自哪里?

这里是迁移的代码:

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

class CreateTodoTable extends Migration
{
/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    //
    Schema::create('todos', function (Blueprint $table) {
        $table->increments('id');
        $table->string('text');
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    //
    Schema::dropIfExists('todos');
}
}

【问题讨论】:

    标签: php laravel


    【解决方案1】:

    Laravel 没有 create_table 方法。这意味着您尝试在某处使用此名称,而不是使用 create

    所以,搜索create_table,将其更改为create。然后运行composer duphp artisan migrate 命令。

    【讨论】:

    • 是的,我使用了 create_table 这个名称,但将其重命名为 create。在命令 du 之后错误仍然存​​在(我想这是重置)。 RegisterController.php 中有一个 create_table 函数,但它是原始创建用户迁移的一部分。
    • @puolimatkankrouvi 然后在RegisterController 中修复它。如果您不能这样做,请出示此控制器。
    • 好的!我确实找到并替换了 create_table -> create 并且它在任何地方都改变了它们,现在它可以工作了。
    猜你喜欢
    • 2014-12-11
    • 1970-01-01
    • 2017-06-25
    • 2022-12-21
    • 2021-12-30
    • 2018-10-03
    • 2016-10-22
    • 2019-09-23
    • 1970-01-01
    相关资源
    最近更新 更多