Laravel: 5.7.25
PHP 7.2.10
Пример данных в ответе
{,…}
data: [{id: 1,…}, {id: 2,…}, {id: 3,…}, {id: 4,…}, {id: 5,…}, {id: 6,…}, {id: 7,…}, {id: 8,…}, {id: 9,…},…]
0: {id: 1,…}
carModelBodyType: {id: 1, name: "Sedan", status: 1, created_at: "2019-01-03 13:25:46", updated_at: "2019-01-03 13:25:46"}
id: 1
insuranceProvider: {id: 1, name: "The Oriental Insurance Company Ltd", has_logo: null, recommended_partner: 1,…}
base_commission_amount: 0
base_commission_percentage: 10
bonus_amount: 0
bonus_percentage: 2
has_logo: null
id: 1
name: "The Oriental Insurance Company Ltd"
planBenifits: [,…]
0: {id: 83, insurance_providers_id: 1, year: 2019, effective_date: "2019-01-27 00:00:00", plan_type: 0,…}
1: {id: 84, insurance_providers_id: 1, year: 2019, effective_date: "2019-01-27 00:00:00", plan_type: 0,…}
2: {id: 85, insurance_providers_id: 1, year: 2019, effective_date: "2019-01-27 00:00:00", plan_type: 0,…}
В представлении
@foreach ( $car_premium_details as $car_premium_detail )
{{ var_dump($car_premium_detail->insuranceProvider->name) }} //Getting correctly
{{ var_dump($car_premium_detail->insuranceProvider->planBenifits) }} //Getting null
@endforeach
Представление обрабатывается с помощью ajax с использованием функции view()->render()
.
Снимок экранаответ