Pluck only name from a nested array

Posted 1 week ago by mykelcodex

Please how do i pluck only name from the product_name array, so that i can display the names of item the user purchased...

array:3 [▼
  "status" => true
  "message" => "Verification successful"
  "data" => array:24 [▼
    "id" => 150482915
    "domain" => "test"
    "status" => "success"
    "reference" => "Xp5CSjuhQqGVffb9Wd5URHB25"
    "amount" => 77000
    "message" => null
    "gateway_response" => "Successful"
    "paid_at" => "2019-04-15T03:01:52.000Z"
    "created_at" => "2019-04-15T03:01:46.000Z"
    "channel" => "card"
    "currency" => "NGN"
    "ip_address" => "105.112.41.91"
    "metadata" => array:4 [▼
      "name" => "Oke Michael"
      "phone" => "08168696515"
      "address" => "5, Akindele Lane, Fardock Estate Ifako Ijaye, Lagos"
      "product_name" => array:2 [▼
        "bb4a6db4295d6be8bd12791ed5650087" => array:8 [▼
          "rowId" => "bb4a6db4295d6be8bd12791ed5650087"
          "id" => 14
          "name" => "Book details"
          "qty" => "1"
          "price" => 30000
          "options" => []
          "tax" => 0
          "subtotal" => 30000
        ]
        "8b486433ba8a9e4089eafa927840a692" => array:8 [▼
          "rowId" => "8b486433ba8a9e4089eafa927840a692"
          "id" => 13
          "name" => "Oke Michael"
          "qty" => "1"
          "price" => 47000
          "options" => []
          "tax" => 0
          "subtotal" => 47000
        ]
      ]
    ]
    "log" => array:8 [▶]
    "fees" => 1155
    "fees_split" => null
    "authorization" => array:12 [▶]
    "customer" => array:8 [▶]
    "plan" => null
    "paidAt" => "2019-04-15T03:01:52.000Z"
    "createdAt" => "2019-04-15T03:01:46.000Z"
    "transaction_date" => "2019-04-15T03:01:46.000Z"
    "plan_object" => []
    "subaccount" => []
  ]
]

I tried this

{{ array_get($tran,'metadata.product_name.name') }}

but it didn't work

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

Reply to

Use Markdown with GitHub-flavored code blocks.