I'm learning Laravel
now, and out of curiosity I came across the following problem, doing a join between two tables, in my case, " categorias
" and " subcategorias
", when I'm going to list the subcategorias
.
It looks for the name of the category to which it is related and displays it, I know it would be easier using DB::
, but for curiosity and learning would like to know how to do it in Eloquent
?
Table Categories
id_categoria - PK
nome_categoria
Table Subcategories
id_subcategoria - PK
nome_subcategoria
idcategoria_subcategoria - armazena o id da categoria