I'm presently learning Laravel and Eloquent, and have set up some initial migrations to play with. One of my tables only needs a creation time, since once a row is inserted there, it will never be updated:
// The run table only needs a creation timestamp, not an updated timestamp
Schema::create('runs', function (Blueprint $table) {
$table->increments('id');
$table->timestamp('created_at');
});
I understand that Eloquent by default expects both a created_at
and an updated_at
column to be present, and that this feature can be turned off entirely. From the manual:
By default, Eloquent expects created_at and updated_at columns to exist on your tables. If you do not wish to have these columns automatically managed by Eloquent, set the
$timestamps
property on your model to false.
However, is it possible for Eloquent to be asked to automatically set a creation time and not an update time? I realise I can do this manually, but it would be nice if Eloquent could do this "for free".