Answer the question
In order to leave comments, you need to log in
What is the best way to do user balance in laravel?
Tell me, I want to make the user a balance in points and a history of points accrual / write-off, how best to make a separate table amount and amounthistory or make the amount field in the Users table. Maybe there is a similar solution?
Answer the question
In order to leave comments, you need to log in
make tables
accounts -> user_id, amount
accounts_history -> user_id, account_Id, date, amount (plus or minus if expense), description
you can make one to one - if the user has only one account
or one to many if there are many accounts.
There are ready ones, you just have to look.
The transaction history table is needed. And here's how to store the remainder in the user table or calculate it dynamically, it's up to you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question