You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a pivot table for two models and the eloquent relationships are also defined. I'm getting this error when I run my static analysis: Access to an undefined property App\Models\InvestmentServiceProvider::$pivot from the third line of code below:
$investmentServiceProviders = $financialGoal->investmentServiceProviders;
foreach ($investmentServiceProvidersas$investmentServiceProvider) {
$amount = $investmentServiceProvider->pivot->amount; //trying get this value from the pivot table//
}
These are my model relationship methods in the FinancialGoal and InvestmentServiceProvider models respectively:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have a pivot table for two models and the eloquent relationships are also defined. I'm getting this error when I run my static analysis:
Access to an undefined property App\Models\InvestmentServiceProvider::$pivot
from the third line of code below:These are my model relationship methods in the
FinancialGoal
andInvestmentServiceProvider
models respectively:This is my pivot table migration code:
I believe this follows the Laravel docs and should work and I'm at a loss as to why it's not.
Beta Was this translation helpful? Give feedback.
All reactions