如何使用迁移在没有 created_at 和 Updated_at 列的情况下在 laravel 中创建 table

How to create table in laravel without created_at and Updated_at column using migration

谁能知道如何使用迁移在 laravel 中创建 Table 而无需在 table 中创建 created_at 和 Updated_at 列。 我尝试了以下代码,但它仍然在 table 中创建 created_at 和 Updated_at 列:-

迁移Laravel:-

<?php

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

class CreateNewusersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('newusers', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->text('name');
            $table->string('email', 100)->unique();
            $table->bigInteger('phone_no');
        });
    }

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

将此添加到您的模型中

public $timestamps = false;