Is it possible to move the created_at
, updated_at
& deleted_at
columns in a Laravel Eloquent model/table to a related table?
The reason I ask is that I want to use this functionality on a table that I cannot change the schema of. As such, I was hoping I could set up a 1-to-1 relationship to a metadata
table containing these columns. This would give me their benefits without having to alter the original table.
you could set public $timestamps = false;
in the model, but that would only fix half the problem, getting a 1-1 relationship would still require a schema change.
i'm thinking you could have a many-many relationship with the metadata (even though you won't add more than one metadata per post), but that would enable you to have a post_metadata table with the pivots.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.