Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timestamps in Laravel 5 got 0000-00-00

I have just started using Laravel 5 and I have problem with timestamps. When I seed a table, everything going good and I get e.g.

created_at
"2015-04-04 20:02:21"

updated_at
"2015-04-04 20:02:21"

But when i use Order::insert(array()) i get:

created_at
"0000-00-00 00:00:00"

updated_at
"0000-00-00 00:00:00"

In laravel 4 I need not set timestamps manually, so I believe, I need not do it there too.

like image 328
Sergey Avatar asked Feb 04 '26 20:02

Sergey


1 Answers

As I can see you're using Eloquent. Instead of using insert() method you should create new record in DB like this:

$order = new Order;
$order->save();

In this case Eloquent will maintain the created_at and updated_at columns on your database table automatically

like image 181
Limon Monte Avatar answered Feb 06 '26 09:02

Limon Monte



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!