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

mkarakaya's avatar

3 Table Relation

Hi, i want to set relation between 3 tables with models in one method (hasManyThrough etc.) my tables;

-hotels
	-id
-certificate
	-id
	-name
-certificate_list
	-certificate
	-hotel
0 likes
2 replies
mkarakaya's avatar
mkarakaya
OP
Best Answer
Level 3
 return $this->belongsToMany(
            'App\Certificate',
            'App\CertificateList',
            'hotel',
            'certificate'
        );

Worked for me.

Please or to participate in this conversation.