How to disable created_at and updated_at timestamps in Laravel Model?

How to disable created_at and updated_at timestamps in Laravel Model?

By default, Laravel Eloquent maintain two columns created_at and updated_at in your database tables automatically you just need to add these two columns in your tables and Eloquent will take care of the rest.

If you create table by following Laravel special schema builder then it create by default these two columns by using $table->timestamps();.This is very useful sometime to deal with last edit data on a specific table

Sometime if this is not so useful and you do not want that Eloquent will maintain these two columns then you can disable it by adding following timestamp property false to your model :

  1. class Product extends Eloquent {
  2. protected $table = 'products';
  3. public $timestamps = false;
  4. }

You can check if it is working or not then save any record in table and see these two columns will have null value if you set timestamps property false.

If you want to disable one timestamps for updated_at only then you can write a mutator for the same column which you want to disable.

  1. public function setUpdatedAt($value)
  2. {
  3. // Do nothing.
  4. }

Same you can do with created_at column if you need to disable only created_at column.

Phone: (+91) 8800417876
Noida, 201301
sakarya escort akyazı escort arifiye escort erenler escort eve gelen escort ferizli escort geyve escort hendek escort otele gelen escort sapanca escort söğütlü escort taraklı escort
sakarya escort | sakarya escort | adapazarı escort | sakarya escort | sakarya escort | sapanca escort | sakarya escort | sakarya escort | serdivan escort | sakarya escort | karasu escort | sakarya escort | sakarya escort | sapanca escort | sakarya escort | sakarya escort | sakarya escort | sapanca escort | sakarya escort | hendek escort bayan sakarya escort adresleri.