mardi 26 avril 2016

Laravel Check if Users have this same relation

I would like to check if two users have these same relation. I have models: User and Team.

User relations:

public function teams()
    {
        return $this->belongsToMany('App\Team');
    }

Team relation:

public function users()
    {
        return $this->belongsToMany('App\User');
    }

So users can be part of few teams. How to check if 2 specified users have common team?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire