';型号名称->;保存';不会';在laravel中,不要正确引用数据库中的标签名称


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

我正在努力学习laravel,并正在学习的一系列教程

我正试图将我在模型中创建的对象保存到我的数据库表联系人中,但当我在修补程序中执行modelObject->save命令时,它会将我的表名替换为联系人,而不是联系人

现在我知道了laravel中的snake大小写复数名称系统,所以我明确地将模型中的表重命名如下:

 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'是我后来手动添加的

现在我在修补程序中创建对象为:

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

然后尝试使用将对象保存到数据库

 $contact->save

但正如我之前所说,laravel试图将其保存到联系人,而不是联系人表

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

我想我做错了什么,显然每次更改我创建的模型类中的某些内容时,我都必须重新启动修补程序。再次引用App/modelClass编写基于对象似乎不起作用