'modelName->save' 在 laravel 中没有正确引用数据库中的表名

'modelName->save' doesn't reference the name of the tabel in the database correctly in laravel

我正在努力学习 laravel,并且正在学习大量教程

我正在尝试将我在模型中创建的对象保存到我的数据库 table-contact,但是当我在 tinker 中执行 modelObject->save 命令时,它会替换我的 table 名称通过联系人而不是联系人

现在我知道 laravel 中的蛇形复数命名系统,所以我在模型中明确重命名我的 table 如下:

 protected $table='contact';

但我仍然得到与

相同的错误
`'base table or view not found **laravel.contacts**'` 

这是我的迁移:

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

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

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

我创建的模型是这样的:

php artisan make:model contact

创建的模型:

  <?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class contact extends Model
{
    protected $table='contact';
}

注意:protected $table='contact'是我后来手动添加的

现在我在 tinker 中创建对象为:

$contact=new App\contact
    $contact->address='myaddress'
    $contact->email='myemail'

然后尝试使用

将对象保存到数据库
 $contact->save

但是就像我之前说过的那样 laravel 尝试将其保存到联系人而不是联系人 table

此外,对象 '$contact' 没有像教程中那样引用模型中的时间戳和 ID 的默认值,可能有人可以提示我为什么..

我发现我做错了什么,显然我每次在我创建的模型 class 中更改某些内容时都必须重新启动 tinker。再次编写引用 App/modelClass 的基础对象似乎不起作用