You can look at this piece of documentation that how you can retrieve it.
https://laravel.com/docs/8.x/eloquent-relationships#retrieving-intermediate-table-columns
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
HI All, I'm pretty sure I'm missing something obvious and would appreciate it if someone could point me in the right direction. To simplify, I have 3 tables and 3 associated models.
Company
ID
Name
Settings
ID
Name
SettingToCompany
ID
company_id
setting_id
value
There will only be one instance of each setting per company. So assuming an entry in the company table with an ID of 1 and name of 'Dummy Company' and two entries in the settings table with the IDs of 1 and 2 with names of 'Setting1' and 'Setting2' - My SettingToCompany table would look like this:
|ID | company_id | setting_id | value|
|1 | 1 | 1 | hello|
|1 | 1 | 2 | word|
I have a function in my company model, that gets the settingToCompany values, based on my current company. I would like to also return the name associated with the setting within the same function?
You can look at this piece of documentation that how you can retrieve it.
https://laravel.com/docs/8.x/eloquent-relationships#retrieving-intermediate-table-columns
Please or to participate in this conversation.