when using eloquent, you can see from the official document that you can customize the insert field and update the field name, with the link https://laravel-china.org/doc.
. Next, give the design of the data table:
CREATE TABLE `plans`(
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`title` varchar(100) NOT NULL,
`content` mediumtext,
`status` tinyint(1) NOT NULL DEFAULT 0,
`create_time` TIMESTAMP,
`update_time` TIMESTAMP,
PRIMARY KEY(id),
FOREIGN KEY(user_id) REFERENCES users(id)
)ENGINE=INNODB;
because I am using the mysql5.6 version, I support setting two timestamp types, but after this setting, I understand that the two fields are created at the same time, but after I update the data, the two fields are still at the same time after the update, which is particularly difficult for me to understand. Then I tried it for a period of time and abandoned this method, so I used the native statement to update the update_time to the current time at the same time. However, I found that create_time has also been updated, or the two time periods can be the same. I would like to ask if there is a good way without changing the field type of the data table, because all my small projects are almost finished, I found this problem and want to find a good solution
.