Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0
Solution

Hi, Diego. This is solution 4 you:

class Categoria extends Eloquent {

    protected $table = 'categorias';
    
    public function subcategorias()
    {
        return $this->hasMany('Subcategoria', 'categoria_id');
    }
    
    public function anuncios()
    {
        return $this->hasManyThrough('Anuncio', 'Subcategoria', 'categoria_id', 'subcategoria_id');
    }
    
}
Last updated 2 years ago.
0

Works like a charm! tanks!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

hernandev hernandev Joined 31 Jan 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.