P-Torres
2 years ago

Mailgun, how to echo Mailgun response on a blade view. Nested array

Posted 2 years ago by P-Torres

Hi, I've got the following response from Mailgun.

{#345 ▼
  +"http_response_body": {#339 ▼
    +"domain": {#334 ▶}
    +"receiving_dns_records": array:2 [▼
      0 => {#340 ▼
        +"cached": array:2 [▼
          0 => "10 mxb.mailgun.org"
          1 => "10 mxa.mailgun.org"
        ]
        +"priority": "10"
        +"record_type": "MX"
        +"valid": "valid"
        +"value": "mxa.mailgun.org"
      }
      1 => {#341 ▶}
    ]
    +"sending_dns_records": array:3 [▶]
  }
  +"http_response_code": 200
}

I want to be able to echo in a view something like:

Type: TXT

Priority: 10

Value: mxa.mailgun.org

Type: TXT

Priority: 10

Value: mxb.mailgun.org

The following code prints "10 10". Anyone any advice... much appreciated, thank you.

@foreach($result->http_response_body->receiving_dns_records as $obj)
    {{ $obj->priority }}
@endforeach

Please sign in or create an account to participate in this conversation.