mardi 24 juillet 2018

how to sort results based on pivot table in laravel

i have three table like this :

  • tour (id name) -> assume (id:1 , name : something)
  • meta (id key) ->assume (id:1 , key: tour_duration)
  • meta_tour (tour_id meta_id value) ->assume (tour_id:1 , meta_id:1 , value: 15)

it's ManyToMany relationship.

i want to sort tours based on meta value in meta_tour table like this :

tours orderBy tour_duration.value



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire