Given that a pivot table has $table->timestamps(); within it's up() migration method, timestamps should be updated upon save, insert etc.
created_at and updated_at remain at: 0000-00-00 00:00:00.
I notice this long ago but thought it was intended... I am new to using an ORM so just don't know..
@Robbo- I can't imagine why this would be intended as it serves no useful purpose to not update the pivot table.
Found this in the docs:
return $this->belongsToMany('Role')->withTimestamps();
Nial... Use the withTimestamps method.
Thanks taylorotwell!!. Worked like a charm.
I know this is old, but I found an error when using timestamps with non standard column names.
If I use withTimestamps() in my relation without arguments, instead of using the columns from the pivot table, it uses the ones from the model attaching the relation.
If I give my column names as arguments, they are ignored, but not the other columns used in attach() method.
Example:
Relation:
$this->belongsToMany('OtherStuff', 'pivot', .....)->withTimestamps();
$object->otherStuff()->attach($id, ['status' => 'SOME STATUS']);
will trigger error, as the columns guessed as timestamps actually belong to $object
$this->belongsToMany('OtherStuff', 'pivot', .....)->withTimestamps('my_created_at', 'my_updated_at');
$object->otherStuff()->attach($id, ['status' => 'SOME STATUS']);
will not trigger error, but the columns will be 0000-00-00 00:00:00
Should I post another issue or is it ok to keep it here?
Most helpful comment
Found this in the docs: