Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

yo81's avatar
Level 4

relationship with 3 tables and condiction

Hi guys ( my first discussion)

TABLE USERS id, username, typology_id

TABLE TYPOLOGIES id, status(on,off)

TABLE TYPOLOGIES_LANG id, typology_id, name, lang(en,de,fr,it)

  • Users can only have one typology
  • Typologies may have many languages

MODEL USERS class User extends Authenticatable {

public function typology(){

    return $this->belongsTo('App\Typology', 'typology_id');
}

}

MODEL TYPOLOGY

class Typology extends Model {

public function typologylang()
{
    return $this->hasMany('App\TypologyLang');
}

}

MODEL TYPOLOGYLANG class TypologyLang extends Model {

}

I would like a list of users with typology with a specific lang ( for example "en").,HOW ? I'm trying but still nothing,thanks

0 likes
1 reply
ctroms's avatar

Have a look at Eloquent's Has Many Through relationship.

You can access the typolang's distant users relationships through the Typology model.

1 like

Please or to participate in this conversation.