Call to undefined method Illuminate\Http\Response::json() in Laravel5
You are using:
Illuminate\Http\Response
and should use this instead:
\Response
Type:
use Response;
Don't type:
use Illuminate\Http\Response;
Try the helper function:
return response()->json(['data'=>$events]);
See the docs in \Illuminate\Routing\ResponseFactory:
/**
* Return a new JSON response from the application.
*
* @param string|array $data
* @param int $status
* @param array $headers
* @param int $options
* @return \Illuminate\Http\JsonResponse
*/
public function json($data = [], $status = 200, array $headers = [], $options = 0)
{
if ($data instanceof Arrayable && ! $data instanceof JsonSerializable) {
$data = $data->toArray();
}
return new JsonResponse($data, $status, $headers, $options);
}