I have two database tables, expenses and incomes and I created a MySQL view, transactions, which basically is an UNION between the two tables, selecting the fields I am interested in.
The transactions view contains the following columns:
I created an Eloquent Model for the view, called Transactions.
The problem is when I want to retrieve transactions based on certain criteria.
E.g. I want to get all transactions for a User. Normally, if transactions was a table, I would define a foreign key relationship and I would simply call
Since foreign keys are not possible for views, I tried using the 'where' method:
. This query does not return anything, neither do any other queries I tested. The only method that returned data is
, but this doesn't help me very much.
What am I doing wrong?