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

Zob*_*mov 2 database-migration laravel

任何人都可以知道如何使用迁移在表中没有 created_at 和 Updated_at 列的情况下在laravel中创建表。我尝试使用以下代码,但它仍然在表中创建 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');
    }
}

Run Code Online (Sandbox Code Playgroud)

小智 5

将此添加到您的模型中

public $timestamps = false;
Run Code Online (Sandbox Code Playgroud)