To disable created_at and updated_at timestamps in laravel apps; Through this tutorial, i am going to show you how to disable created_at and updated_at timestamps in laravel apps.
How to Disable created_at and updated_at Timestamps in Laravel
Here, i will show you two methods to disable created_at and updated_at timestamps in laravel; as follows:
- Solution 1 – To disable created_at and updated_at timestamps from Model
- Solution 2 – To disable created_at and updated_at timestamps from Migration
Solution 1 – To disable created_at and updated_at timestamps from Model
To declare public $timestamps = false;
in laravel model to disable timestamp:
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Item extends Model { protected $fillable = ['title','content']; public $timestamps = false; }
Solution 2 – To disable created_at and updated_at timestamps from Migration
To disable timestamps by removing $table->timestamps()
from your migration file; as follow:
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 }); }
Be First to Comment