Laravel: MySQL auto-updates my updated_at field everyday without any update on article -


i worked on blog application using laravel 5.4 on localhost , working fine. however, when uploaded application on remote server on internet, updated_at field on every post kept updating automatically every day.

the same code when run on local machine works fine , updated_at field updated when post updated. guessing problem @ level of database configuration have no idea how fix that.

the source code: migrations

schema::create('posts', function (blueprint $table) {     $table->increments('id');     $table->string('title');     $table->string('featured_image');     $table->string('slug')->unique();     $table->text('body');     $table->boolean('published')->default(false);     $table->unsignedinteger('user_id');     $table->integer('views')->default(0);     $table->timestamps();     $table->softdeletes();      $table->foreign('user_id')->references('id')->on('users'); }); 

and have in model post.php:

    protected $dates = ['created_at', 'updated_at', 'deleted_at']; 

i adding source code benefit of doubt because same source code runs on localhost , produces desired result.

it because views field updated each view users.

you can disable updating timestamp fields before increasing view :

$obj->timestamps = false; $obj->views += 1; $obj->save(); 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -