2
I have a table called clientes
and this table has a column status
which may have +/- 3 types (novo, cancelado, pendente...)
need to display a quantity of information separated by status
, and instead of doing it with 3 queries, sendo
a Where for each status, I wonder if it is possible in a single query to return the 3 status with a minimum amount of each one of them:
Current example:
Cliente::where('status', 'novo')->take(20)->get();
Cliente::where('status', 'cancelado')->take(20)->get();
Cliente::where('status', 'pendente')->take(20)->get();
it is possible, in a single query, to return 20 results for each different status?
There is no way you can build what you want the way you are proposing, understand that status is a one-to-one relationship and resides in another table. However you can create correctly, note that what you want to do is look at from the point of view of STATUS and not from the customer, so you will be required to use the STATUS model and not client to assemble the query.
– Newton Pasqualini Filho
actually, the status is on the same table, it’s just a table
– Thiago
Some answer got your problem???
– novic