I have a table and related model that has a custom timestamp. The migration is set like this:
Schema::create('tests', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamp('expire_at');
$table->timestamps();
});
And I have set up my Model like so:
class Test {
protected $dates = [
'expire_at'
];
}
When I try to update the name field only, it sets the expire_at
field as same as updated_at
field rather than simply not changing it.
$test = Test::find(1);
$test->name = "Changed Value";
// Until here, the expire_at timestamp has its true value
// but on save(), it changes expire_at to updated_at time.
$test->save();
Is there anything I am doing wrong with the protected $dates
usage?