我在Laravel迁移基础视图/表中发现了一个奇怪的错误1146


I got strange error in Laravel migration base view/table not found 1146

我确实用这个迁移文件从laravel进行了迁移

    <?php
use Illuminate'Database'Schema'Blueprint;
use Illuminate'Database'Migrations'Migration;
class MsCustomer extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('mscustomer', function(Blueprint $table)
        {
$table->increments("custid");
            $table->string("custname");
            $table->string("password");
            $table->string("email")->unique();
            $table->integer("balance");
            $table->string("role");
            $table->timestamps();
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('mscustomer');
    }
}

然后它成功了,在我的数据库中创建了一个名为"mscustomer"的表,然后我试图通过调用一个模型来使用php手工修补程序,该模型是mscustomer.php,它包含

<?php namespace App;
use Illuminate'Database'Eloquent'Model;
class mscustomer extends Model {

}

然后我得到这个错误"Illuminate''Database''QueryException,消息为'SQLSTATE[42S02]:找不到基表或视图:1146表'twk.mscustomers'不存在……"

我不明白的是,我清楚地创建了mscustomer,但为什么它在后面找"twk.mscustomers"(带"s"),而不是twk.msccustomer。在这种情况下我犯了什么错误吗?

请帮帮我。

注意:很抱歉提问方式不好,这是我第一次在这里提问。

这就是Laravel的工作原理。Eloquent将假定模型类名的复数形式作为表名。您可以通过添加属性来覆盖此行为:
class mscustomer extends Model {
    protected $table = 'mscustomer';
}

此外,使用以大写字母开头的类名也是相当标准的。在您的情况下,Mscustomer(或可能是MsCustomer)而不是mscustomer