adplus-dvertising

how to make mysql columns value depend on other columns

Asked 3 months ago
Viewed 6 times

Stack: Laravel v8, MySQL.

I working on a payroll system with Laravel.

I want the value of some columns to update if another column it depends on changes.

For example, if the Number of working days changes on the payrolls table, then the salary and other columns that depends on 'Number of working days' column should re-calculate based on the new value and save to the database.

How do I go about this? Are there any Laravel packages that handles this efficiently?

asked 3 months ago

Correct Answer

I never tried it myself, but it seems like you could solve this with a MYSQL Trigger or event:

https://dev.mysql.com/doc/refman/8.0/en/trigger-syntax.html

answered 3 months ago