I have an object in my database that I am trying to retrieve in the Model and parse through to display the text in the blade template. I am not quite sure how to get this to parse correctly. Thank you.
public function getStep1()
{
$step1 = $this->details()->get();
foreach($step1 as $step1)
{
$step1 = $step1->step_1;
return $step1;
}
}
This gets me the following output that I don't know how to parse through. I have tried $step1[0], but that just gives me a [ nothing else.
[["$50,000-$100,000","More than $100,000"]]
My Blade template is simply this...
{{ $question->getStep1() }}
Thank you for your help.
Update:
When I do a var_dump, it says that my "steps" are stored as strings. Is that what's causing a problem? I still can't get within the [].
array (size=9)
'id' => int 1
'question_id' => int 55
'step_1' => string '[["$50,000-$100,000","More than $100,000"]]' (length=43)
'step_2' => string '[["Step2-option1","Step2-option2","Step2-option3"]]' (length=51)
'step_3' => string '[["Step3-option2"]]' (length=19)
'step_4' => null
'step_5' => null
'created_at' => string '2018-10-03 12:29:05' (length=19)
'updated_at' => string '2018-10-03 12:29:05' (length=19)