Features Value in Plans

Laraship QuestionsCategory: TechnicalFeatures Value in Plans
Arif Hidyawan asked 6 years ago

Hi,

How to show features value from Plans? I try to use {{ $plan->featureName}} but error 500.

Thanks

1 Answers
laraship Staff answered 6 years ago

Hello,

The relation between plans and features are one to many as each plan has many features, to get features values you need to loop or query by specfic feature

for example

    foreach ($plan->features as $feature) {

$featuresPairs[$feature->name] = $feature->pivot->value;

}

or

$plan_feature = $plan->features()->where('feature_id',$feature->id)->first());

$plan_feature_value = $plan_feature->pivot->value;