I have two models, Product and Attribute. There is a 'product_attributes' joining table between 'products' and 'attributes'. The relationship is defined in both models using belongsToMany(), and the key of the table is a compound one of product_id and attribute_id.
I can successfully retrieve and store records in the joining table - so, as such everything is functioning as expected, with the exception that the created_at and updated_at in product_attributes is not being set.
Is the above by design, and is there anything I can do to rectify this?
You should use the belongsToMany function with the timestamps declaration like this:
$this->belongsToMany(<entity>)->withTimestamps();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With