php - Eloquent model not updating updated_at timestamp -
i'm using laravel 5.1. make simple, have following code
migration:
schema::create('sitemap_data', function (blueprint $table) { // primary , foreign keys $table->increments('id'); $table->string('posturl'); // database functions $table->timestamps(); }); and code somewhere else i'm using
$sitemapdata = sitemapdata::firstornew([ 'posturl' => $post ]); $sitemapdata->save(); now, according laravel documentation
again, updated_at timestamp automatically updated, there no need manually set value
the updated_at value should updated in table. however, not happening.
it get's set on first insert, not on updating. when manually, this
$sitemapdata = sitemapdata::firstornew([ 'posturl' => $post ]); $sitemapdata->updated_at = carbon::now(); $sitemapdata->save(); it works. however, docs should happend automatically, wrong here?
i've searched sites on stackoverflow question, ones found laravel 3 or 4.1, 4.2 etc.
how correctly?
as mentioned in comments, if model did not change timestamps wont updated. if need update them, or want check if working fine use $model->touch() - more here
Comments
Post a Comment