How to sort collections by specific value and id. I need to sort records where the name = X should be the first in the order.
product model
|---------------------|------------------|
|          id         |        Name      |
|---------------------|------------------|
|          1          |         a        |
|---------------------|------------------|
|          2          |         x        |
|---------------------|------------------|
|          3          |         b        |
|---------------------|------------------|
|          4          |         c        |
|---------------------|------------------|
|          5          |         x        |
|---------------------|------------------|
I tried this code but not working.
Product::orderBy('id', 'asc')->get()
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire