Я пытаюсь отобразить результаты json в блейде, но когда я пытаюсь отобразить название штата, название района из соответствующих отношений, я получаю 1 в блейде, я могу отобразить ' отношение пользователя и новая установка.
Моя модель
Новая установка. php
public function newInstallationPrePayment()
{
return $this->hasMany(NewInstallationPrePayment::class, 'installation_order_id', 'id');
}
public function state()
{
return $this->hasOne(State::class, 'id', 'state');
}
public function district()
{
return $this->hasOne(District::class, 'id', 'district');
}
Новая установкаПлатаСтатус. php
public function newInstallationPrePayment()
{
return $this->belongsTo(NewInstallationPrePayment::class, 'order_name', 'order_name');
}
Контроллер
$new_installation_order = NewInstallationPaymentStatus::with([
'newInstallationPrePayment.newInstallation.state',
'newInstallationPrePayment.newInstallation.district',
'newInstallationPrePayment.newInstallation.user']
)->findOrFail($id);
Blade
{{$new_installation_order}}
Я получаю ниже json результат для вышеупомянутого
Но когда я пытаюсь вызвать состояние
{{$new_installation_order['newInstallationPrePayment']['newInstallation']['district'] }}
Когда я использую это, я получаю 1
Json :
{
"id":2,
"user_id":1,
"order_name":"ORDER_ID_NW_SW-24",
"order_amount":"118.00",
"referenceId":"290927",
"txStatus":"SUCCESS",
"paymentMode":"CREDIT_CARD",
"txMsg":"Transaction Successful",
"txTime":"2020-03-31 14:34:52",
"order_status":"NEW",
"deleted_at":null,
"created_at":"2020-03-31T16:37:34.000000Z",
"updated_at":"2020-03-31T16:37:34.000000Z",
"new_installation_pre_payment":{
"id":21,
"user_id":0,
"installation_order_id":24,
"order_name":"ORDER_ID_NW_SW-24",
"payment_status":"SUCCESS",
"created_at":"2020-03-31T09:04:33.000000Z",
"updated_at":"2020-03-31T16:37:34.000000Z",
"deleted_at":null,
"new_installation":{
"id":24,
"f_name":"Full Name",
"p_no":"",
"address":"Address",
"address_line_1":"Address",
"state":{
"id":1,
"state_name":"Tamil Nadu",
"deleted_at":null,
"created_at":"2020-03-27T04:16:37.000000Z",
"updated_at":"2020-03-27T04:16:37.000000Z"
},
"district":{
"id":1,
"state_id":1,
"district_name":"Chennai",
"deleted_at":null,
"created_at":"2020-03-27T04:17:22.000000Z",
"updated_at":"2020-03-27T04:17:22.000000Z"
},
"area":"Area Name",
"landmark":"Land Mark",
"pincode":"123456",
"fees_id":1,
"user_id":1,
"deleted_at":null,
"created_at":"2020-03-31T09:04:33.000000Z",
"updated_at":"2020-03-31T09:04:33.000000Z",
"user":{
"id":1,
"name":"admin",
"email":"tesmachino@gmail.com",
"email_verified_at":null,
"created_at":"2020-03-29T10:33:36.000000Z",
"updated_at":"2020-03-29T10:33:36.000000Z"
}
}
}
}