-1

I have a storeQuantities() method that stores the quantities of tickets selected by the user in a conference details page.

In this method "dd($selectedRtypes)" shows the content below. The questions is empty because there are no questions associated with this conference.

array:1 [▼
  "geral" => array:5 [▼
    "quantity" => "2"
    "price" => 0
    "total" => 0
    "questions" => Collection {#255 ▼
      #items: []
    }
    "id" => 1
  ]
]

In the registration.blade.php it appears this error:

Undefined index: questions 

With:

@if(is_null($selectedRtypes['questions']))

....

Do you know why?

johnW
  • 309
  • 1
  • 8
  • 26

1 Answers1

1

$selectedRtypes['geral']['questions']

Quezler
  • 2,376
  • 14
  • 29
  • Thanks but "geral" is dynamic, is stored like: "$selectedRtypes[$ttype->name]['questions'] = $ttype->questions". So it can be geral but can other name. – johnW May 27 '18 at 11:40
  • Can you try `$selectedRtypes[0]['questions']` then? it should then return the first item in the array, in case 'geral' is renamed – Quezler May 27 '18 at 11:41
  • Thanks, like that it appears "Undefined offset: 0". – johnW May 27 '18 at 11:43
  • Then give this a try: `collect($selectedRtypes)->first()['questions']` – Quezler May 27 '18 at 11:44