I created such table in database.
Schema::create('packages', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('count'); $table->timestamp('expire_date'); $table->timestamps(); }); Now Imagine we have following records in database:
+----+-------+---------------------+---------------------+---------------------+ | id | count | expire_date | created_at | updated_at | +----+-------+---------------------+---------------------+---------------------+ | 1 | 120 | 2018-01-31 19:22:45 | 2018-01-29 17:12:01 | 2018-01-29 19:22:45 | | 4 | 140 | 2018-02-14 19:05:01 | 2018-01-29 17:20:16 | 2018-01-29 19:05:01 | | 27 | 10 | 2018-02-17 19:01:10 | 2018-01-29 19:05:01 | 2018-01-29 19:05:01 | +----+-------+---------------------+---------------------+---------------------+ when I try to edit a record using laravel eloquent:
$package = \App\Package::find(1); $package->count = 100; $package->save(); save method changes both expire_date and updated_at columns to current time!
+----+-------+---------------------+---------------------+---------------------+ | id | count | expire_date | created_at | updated_at | +----+-------+---------------------+---------------------+---------------------+ | 1 | 100 | 2018-01-29 19:32:24 | 2018-01-29 17:12:01 | 2018-01-29 19:32:24 | | 4 | 140 | 2018-02-14 19:05:01 | 2018-01-29 17:20:16 | 2018-01-29 19:05:01 | | 27 | 10 | 2018-02-17 19:01:10 | 2018-01-29 19:05:01 | 2018-01-29 19:05:01 | +----+-------+---------------------+---------------------+---------------------+ why expire_date value changes without even touching it?!!!