Hi, basically what I want to generate is a query that returns a list of users, whose exact value is the result of the difference between two fields.
That is, I have the user table that has the fields ndias and diasconsumados.
I am currently doing the following
User::where('ndias','-','diasconsumidoss','=','5')->get();
but this doesn't work.
What I want it to do is basically the following. I leave the example of how the SQL query should look
SELECT * FROM `users` WHERE (users.ndias - users.diasconsumidos) =5
The best thing in this case would be to use
whereRaw
. The code would be like this:Also, if you want you can pass the value
5
as a parameter like this:You can use whereRaw