Laravel disable created_at, updated_at timestamps; In this tutorial, you will learn how to disable created_at, updated_at timestamps using model and migration in laravel.
Laravel Disable Created_at, Updated_at timestamps
There are two ways to disable created_at, updated_at timestamps using model and migration in laravel; as shown below:
- To disable created_at and updated_at timestamps from Model in Laravel
- To disable created_at and updated_at timestamps from Migration in Laravel
To disable created_at and updated_at timestamps from Model
You can declare public $timestamps = false;
in your laravel model to disable timestamp; as shown below:
<?php namespace App; use Illuminate\Database\Eloquent\Model; class Item extends Model { protected $fillable = ['title','content']; public $timestamps = false; }
To disable created_at and updated_at timestamps from Migration
You can also disable timestamps by removing $table->timestamps()
from your migration file; as shown below:
public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique()->nullable(); $table->string('provider'); $table->string('provider_id'); $table->timestamp('email_verified_at')->nullable(); $table->string('password')->nullable(); $table->rememberToken()->nullable(); $table->timestamps(); // remove this line for disabling created_at and updated_at date }); }