I\'m using Laravel 5.1. To make it simple, I have the following code
Migration:
Schema::create(\'sitemap_data\', function (Blueprint $table) {
// Pri
go to phpmyadmin and select your db and select the table tap on SQL tab above and type for example something like this:
UPDATE `boshogriq_table` SET `updated_at`= DATE_ADD(`created_at`, INTERVAL 1 MINUTE)
WHERE `updated_at` > DATE_ADD(`created_at`, INTERVAL 10 MINUTE)
run it by go button. Laravel won't allow you do this
As mentioned in comments, if the model did not change the timestamps wont be updated. However if you need to update them, or want to check if everything is working fine use $model->touch()
- more here
This is not the case in the question, but same issue will happen if you're using Query Builder instead of Eloquent Model.
If you do
DB::table('users')->where()->update()
instead of
User::where()->update()
updated_at will not be updated.
It is possible actually:
$model->updated_at = Carbon::now();
$model->save(['timestamps' => FALSE]);
That will properly save the updated_at
to now. If you're not sure if any of the model's columns have changed, but you do want to update the updated_at
regardless - this is the way to go.
Yeah what Musterknabe has done is correct but he should also check his model SitemapData.php it should have to have set $timestamps = true;
<?php
class SitemapData extends Eloquent {
public $timestamps = true;
}