Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel - after removing updated_at and created_at columns from database laravel tries to insert into them

I have deleted created_at and updated_at from database but laravel tries to insert into these columns however I have deleted both from database and code in controller. I think something is cached. BTW I don't want to use public $timestamps = false in model because it seems they are extra and unneeded.

like image 526
codepro Avatar asked Dec 21 '25 10:12

codepro


1 Answers

Well, in fact you need to set:

public $timestamps = false;

and it's not extra and unneeded because by default it's assumed models have timestamps (and in fact it's very reasonable to keep them almost in all tables).

Timestamps are used in process of saving record:

if ($this->usesTimestamps()) {
    $this->updateTimestamps();
}

so there is no other shorter way when you are using Eloquent to set this property to false when you don't have those columns in table.

like image 198
Marcin Nabiałek Avatar answered Dec 24 '25 01:12

Marcin Nabiałek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!