Answered by : sazzad-hossain-nirjhor-h1whv1vt0dd3
//json encode
return response()->json([ 'name' => 'Abigail', 'state' => 'CA',
]);
//now decode
$response = json_decode($response->getContent()) ;
Source : | Last Update : Tue, 31 May 22
Answered by : important-ibex-z3ykm5lywf7k
return response()->json(['name' => 'Abigail', 'state' => 'CA']);
Source : https://laravel.com/docs/5.1/responses#json-responses | Last Update : Sat, 20 Jun 20
Answered by : witty-wombat-ewhlde8a8h57
return response()->json([ 'name' => 'Abigail', 'state' => 'CA',
]);
Source : | Last Update : Thu, 08 Oct 20
Answered by : innocent-ibis-e2684x93bkb5
return Response::json([ 'hello' => $value
], 201); // Status code here
Source : https://stackoverflow.com/questions/31131159/laravel-return-json-along-with-http-status-code | Last Update : Thu, 12 Mar 20
Answered by : mohammad-maizied-hasan-majumder
//Get output from your browser network.
return response()->json([$laravelVariable]);
Source : | Last Update : Tue, 21 Jun 22
Answered by : revaz-gh
return response()->json($array);
Source : | Last Update : Mon, 24 May 21
Answered by : jareer
Route::get('/status', function () { return response(["success" => true])->header('Content-Type', 'application/json');
});
Source : | Last Update : Wed, 16 Feb 22
Answered by : magnificent-mink-bfhb2a9c83sw
public function getOrgById(Request $request){ // do something here... return response()->json(array('foo' => 'bar'));
}
Source : https://stackoverflow.com/questions/38505750/laravel-5-fetch-ajax-data-in-route-and-pass-to-controller | Last Update : Fri, 30 Jul 21
Answered by : engineer-wajid-ali
$report=json_encode(Teacher::with('students')->get());
return view('admin.index',compact('report'));
Source : | Last Update : Fri, 24 Jun 22