Why not simply have two tables - your user and a simpler movements table
Movements would be something like:
user_id
movement_type (1, incoming, 2 outgoing)
movement_amount
movement_date
You can then do everything
maybe you need to have a 'transactions' table?
sample entry would be
id timestamp user_id incoming outgoing balance
1 2017-07-01 1 20 0 20
2 2017-07-02 1 0 100 120
and so on
so, you could access the 5th day transaction's balance for example as
$balance = $user->transactions()->get(4)->balance
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community