lundi 26 octobre 2015

Get value from relationed table, not his id

I have two tables:

Products

  • id
  • name
  • category_id

Categories

  • id
  • name

In my models I have relations specified and when I get

\Product::all(); return looks something like:

id: 1
name: product Name
category_id: 1

Is it possible to get category name, not his id. I need something like this:

id: 1
name: product Name
category_name: electronics

Thanks a lot



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire