//json encode
return response()->json([
'name' => 'Abigail',
'state' => 'CA',
]);
//now decode
$response = json_decode($response->getContent()) ;
return response()->json([
'name' => 'Abigail',
'state' => 'CA',
]);
return response()->json($array);
Route::get('/status', function () {
return response(["success" => true])->header('Content-Type', 'application/json');
});
public function getOrgById(Request $request){
// do something here...
return response()->json(array('foo' => 'bar'));
}
protected $casts = [
'birthday' => 'date:Y-m-d',
'joined_at' => 'datetime:Y-m-d H:00',
];
$report=json_encode(Teacher::with('students')->get());
return view('admin.index',compact('report'));