A
A
an5432019-02-03 06:09:35
Database design
an543, 2019-02-03 06:09:35

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

2 answer(s)
D
developer007, 2019-02-06
@an543

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.

K
Konstantin B., 2019-02-04
@Kostik_1993

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 question

Ask a Question

731 491 924 answers to any question