【问题标题】:how to fix “Method Illuminate\Database\Schema\Blueprint::number does not exist.”如何修复“方法 Illuminate\Database\Schema\Blueprint::number 不存在。”
【发布时间】:2020-11-05 02:54:16
【问题描述】:

当我使用 php artisan migrate 时,我会收到此消息。有人可以帮我弄这个吗?我在互联网上搜索,但没有找到任何对我有帮助的东西。 (我是 laravel 新手)

我的桌子:

  <?php

use Illuminate\Database\Migrations\Migration;

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Support\Facades\Schema;

class CreateSroomsTable extends Migration

{

    /**

     * Run the migrations.

     *

     * @return void

     */
    public function up()
    {
        Schema::create('srooms', function (Blueprint $table) {
            $table->id();
            $table->string('room_two');
            $table->string('room_three');
            $table->string('room_four');
            $table->string('room_five');
            $table->string('room_six');
            $table->string('room_seven');
            $table->string('room_eight');
            $table->string('room_nine');
            $table->string('room_ten');
            $table->string('room_eleven');
            $table->string('room_twelve');
            $table->softDeletes();
            $table->timestamps();
        });
    }

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

【问题讨论】:

  • 尝试改变$table->id();到 $table->increments('id');
  • 这可能是您的 .env 文件中的错误 MySQL 端口号。检查您的 .env 文件并确保端口号与 MySQL 使用的端口号匹配。
  • 我试过了,但没有解决。我还使用了 $table->increments('id');而不是 $table->id();但我仍然遇到同样的错误。

标签: error-handling laravel-7 artisan-migrate


【解决方案1】:

您将一列声明为如下数字:

[$table->number('')] 

但你应该使用

[$table->integer('')]

【讨论】:

    猜你喜欢
    • 2021-04-12
    • 2022-12-21
    • 2021-12-30
    • 2014-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-21
    • 2018-09-24
    相关资源
    最近更新 更多