Search code examples
laraveldatabase-migration

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


Can anyone know how to create Table in laravel without created_at and Updated_at Column in table using a migration. I try this Following code but it's still create created_at and Updated_at column in table:-

Migration 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');
    }
}


Solution

  • Add this in your model

    public $timestamps = false;