Skip to content
Advertisement

Getting specific column in Laravel relation returning empty array

I want to get specific column from Model relation in Laravel, but the relation model returning empty array.

Eloquent Query

JavaScript

Medicine Modal

JavaScript

Advertisement

Answer

You always need to also select the primary and foreign keys of the table to make the relation work:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement