vendredi 30 décembre 2016

How to assign relationship and fetch data using array field in laravel

There are two models: Restaurant and Category

Restaurant{
  '_id' : 12345678
  'name' : "xyz",
  'abstract' : "awdwadawdawdawd",
  'category': [1,2,3,4] //category ids
}

Category{
  '_id' : 1,
  'name' : 'PQR'
}

How can I assign relationship and fetch all the categories using that array field (category) of Restaurant in laravel 5.3 and Database is mongodb?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire