Good afternoon I need to make a query in laravel but the results are not what I hope, hopefully someone can help me.
And these are the results I want to obtain: that the BRAND be printed only once and then the list of products:
The relationships are the following:
class Marca extends Model {
public function productos()
{
return $this->hasMany(Producto::class,'idmarca');
}}
-----------------
class Producto extends Model
public function categoria()
{
return $this->belongsTo(Categoria::class,'idcategoria');
}
public function marca()
{
return $this->belongsTo(Marca::class,'idmarca');
}
-----------------
class Categoria extends Model
{
public function productos()
{
return $this->hasMany(Producto::class,'idcategoria');
}