I'm using Laravel 5.1. To make it simple, I have the following code
Migration:
Schema::create('sitemap_data', function (Blueprint $table) {
// Primary and foreign keys
$table->increments('id');
$table->string('postUrl');
// Database functions
$table->timestamps();
});
And this is the code somewhere else I'm using
$sitemapData = SitemapData::firstOrNew([
'postUrl' => $post
]);
$sitemapData->save();
Now, according to the Laravel documentation
Again, the updated_at timestamp will automatically be updated, so there is no need to manually set its value
The updated_at value should be updated in the table. However, this is not happening.
It get's only set on the first insert, but not on updating. When I do it manually, like this
$sitemapData = SitemapData::firstOrNew([
'postUrl' => $post
]);
$sitemapData->updated_at = Carbon::now();
$sitemapData->save();
it works. However, the docs say this should happend automatically, so what is wrong here?
I've searched some sites on stackoverflow for this question, but the ones I found where for Laravel 3 or 4.1, 4.2 etc.
How would I do that correctly?