Reputation: 118
Laravel
How to create a column with timestamp which update the time each time if i make any changes to other columns
Upvotes: 1
Views: 1926
Reputation: 6259
I found a simple solution to your problem
for example, if you want to update your user after some changes
$user->touch()
It should be an instance of your model
Upvotes: 1
Reputation: 14278
If you want to add additional column aside from the already given ones for each migration, the created_at
and updated_at
timestamps then when you create a timestamp
column in your database, if you don't specify it manually to be nullable()
then by default it will add the constraint on update CURRENT_TIMESTAMP
.
So in your migration just add the column like this:
$table->timestamp('your_column_name');
Upvotes: 2