2

I am trying to access json in a nested array but it is not working yet.

I am developing in laravel an have this

public function rave(Request $request){


    $vars = [

       'id' => Request::get('id'),
       'txref' => Request::get('txRef'),
       'flwref' => Request::get('flwRef'),
       'created_at' => Request::get('createdAt'),
       'amount' => Request::get('amount'),
       'status' => Request::get('status'),
       'name' => Request::get('fullName'),
       'email' => Request::get('customer'),

    ];

I am able to get and display all in view but name and email which comes back in the response as

"customer":{
    "id":15672,
    "phone":"7667866 ",
    "fullName":"john doe ",
    "customertoken":null,
    "email":"[email protected]",
    "createdAt":"2019-06-09T08:28:56.000Z",
    "updatedAt":"2019-06-09T08:28:56.000Z",
    "deletedAt":null,
    "AccountId":33519
},

How do I access the data under customer because this

'name' => Request::get('fullName'),
'email' => Request::get('customer'),

doesn't seem to work like the others

2
  • try json_decode().. Commented Jun 10, 2019 at 7:08
  • First use json_decode and then customer['name'], customer['email']? This doesnt work? Commented Jun 10, 2019 at 7:15

1 Answer 1

3

You use Request $request as function parameter,

and check output of

echo $request->input('customer.fullName');
echo $request->input('customer.email');
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks 'email' => Request::input('customer.email'), worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.