vendredi 5 mai 2017

custom listing records using conditional

i need some help with my query, basically im trying to get all my order_items on the table, but i need to get all items by user_id, but there is a detail, i want to include also records that includes on a column more than 3 times the the same email on different users_id.

Ex:

table:

- id;
- user_id;
- email;

1- Get all records from mine (user_id); 2 - Get all records where on 3 differentes user_id have the same email value;

Here is my query:

$orders = OrderItem::select('email','user_id')->where('user_id',Auth::user()->id)->distinct('email')->get();



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire