mercredi 29 juin 2016

How do I access request arrays within arrays

I have the following request;

Collection {#278
  #items: array:3 [
    0 => array:2 [
  0 => array:8 [
    "id" => 631
    "name" => "OIL, FILTER O.E.M."
    "partno" => "235-00"
    "oemnumber" => "16099 003"
    "stock" => 0
    "price" => "30"
    "qty" => 1
    "total" => 30
  ]
  1 => array:8 [
    "id" => 23
    "name" => "SPEEDOMETER"
    "partno" => "122-"
    "oemnumber" => "25005 1013"
    "stock" => 0
    "price" => "276"
    "qty" => 1
    "total" => 276
  ]
]
1 => array:2 [
  0 => array:2 [
    "description" => "Oil change"
    "hours" => "1"
  ]
  1 => array:2 [
    "description" => "Tune up"
    "hours" => "2"
  ]
]
2 => array:15 [
  "id" => 1
  "custId" => 9046
  "bikeId" => 5238
  "trans" => "yes"
  "transDetails" => "call cab"
  "policies" => "Yes"
  "locker" => "1"
  "lockerContents" => "stuff"
  "estimate" => "Yes"
  "oldparts" => "Yes"
  "status" => "Pending"
  "created_by" => null
  "created_at" => "2016-05-19 14:40:59"
  "updated_by" => null
  "updated_at" => "2016-06-08 09:06:58"
]
]
}

I am getting this through;

$collection = collect($request->all());

How should I go about accessing the attributes in these arrays? I have tried pluck with no joy. I suspect I could do a loop over them but with no array_expression for the arrays do I need to use the index?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/299REnn
via IFTTT

Aucun commentaire:

Enregistrer un commentaire