0

I've problem get JSON to Laravel

public function finish(Request $request) { $data = Input::all(); dd($data['transaction_status']); } 

But I get

enter image description here

Please help me

7
  • The key is not present. dd($data) and you can see all the data in it. Commented Nov 21, 2018 at 5:49
  • hi @KinshukLahiri but I want see data on transaction_status. What I need to do? Commented Nov 21, 2018 at 5:50
  • U can use $request -> all() Commented Nov 21, 2018 at 5:50
  • Hi @MyatHtut I mean, I want to only see data in transaction_status Commented Nov 21, 2018 at 5:56
  • @rizkyZulkarnaen pls try $data=$request->all(); $data[‘transaction_status’]; Commented Nov 21, 2018 at 5:58

2 Answers 2

1

To retrieve the JSON payload from $request object use :

dd(json_decode($request->getContent(), true)); 
Sign up to request clarification or add additional context in comments.

5 Comments

you should not need to json_decode() as this is done by Laravel automatically
I already use json_decode, but get error json_decode() expects parameter 1 to be string, array given
@rizkyZulkarnaen Please try with only : $data = $request->getContent();
Hi bro @dvl333 I only want show field transaction_status, not all data
@rizkyZulkarnaen Could you please also try with : $transactionStatus= $request->json()->all()['transaction_status'];
0

You should try this:

public function finish(Request $request) { $data = Input::all(); dd($request->transaction_status); } 

Updated Answer

public function finish(Request $request) { $data = Input::all(); dd($request->all()); } 

2 Comments

I only get null bro
@rizkyZulkarnaen: Give me result of my updated answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.