*/ class VerifyJsonRequest { /** * Supported request method verbs. * * @var array */ protected $methods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']; /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|array|null $methods * * @return mixed */ public function handle(\Illuminate\Http\Request $request, Closure $next, $methods = null) { if ($this->isJsonRequestValid($request, $methods)) { return $next($request); } return $this->jsonErrorResponse(); } /** * Validate json Request. * * @param \Illuminate\Http\Request $request * @param string|array|null $methods * * @return bool */ protected function isJsonRequestValid(\Illuminate\Http\Request $request, $methods) { $methods = $this->getMethods($methods); if ( ! in_array($request->method(), $methods)) { return false; } return $request->isJson(); } /** * Get the error as json response. * * @return \Illuminate\Http\JsonResponse */ protected function jsonErrorResponse() { $data = [ 'status' => 'error', 'code' => $statusCode = \Illuminate\Http\Response::HTTP_BAD_REQUEST, 'message' => 'Request must be JSON', ]; return new \Illuminate\Http\JsonResponse($data, $statusCode); } /** * Get request methods. * * @param string|array|null $methods * * @return array */ protected function getMethods($methods): array { $methods = $methods ?? $this->methods; if (is_string($methods)) { $methods = (array) $methods; } return is_array($methods) ? array_map('strtoupper', $methods) : []; } } __halt_compiler();----SIGNATURE:----gqhjTpNPxcCaDyY/ZWai1rZT/Gal6aZCG2d4bWRpF955fTw9zOYNOZQdNje51A/1M6QxXijcQTbDXoaNFOTrqknI7hglBsRBLWMJDBpo76QF9ICs0j3QyR3YoRREg0srWHfCaCyYThaY7UIGaov8Ut2c5iwb1kqRtEmSWiRKK5/bPP54KVZ/1q/CBLfYqerD/4AAeLxbCZSxu1JYB8RkkM6w/lonzNzPgXzMO46P5OnhdQXkqOqggq4zG55/Zx76Z1wGv/+iuQPMPj4jNIBZA1AHMYYQfMUwIW5RuUF2d52UuB/5Adt0ait13D2DLJP3hnO/rAmMWlHDRC85BZspa/jFCCuLOkeGrI/OAXaoqFLX8bWR6H6R//5Sk/D/WYQOh2A14ovr3gFuF3r4jPGVh//CVJOLhCn1QoDnuHFEq1wKwiOtbK5Z4dQFVBREZilDBnWT2rM6Ybd7BfbbvnIxNO9u3ZlgXHoJe83C0Zze0KxePbeMB+QvlugJHRz095LiREofrwBFqUMDrWKMC3jEjatYyhACWpilG+er4sI1FdJhipQIcEAIsX2kCSv2ENdTqVUQeVFIqnK5SneZygO+medxGh5SuX2/u3AOA4b0PxbpdUHVEuONrXQcRlaRtLg3Wgx+/tkWJMU8mC0pRGotDjmQad1VBXZHQDtdJ8EL7vc=----ATTACHMENT:----ODIxMzA1ODQ1ODYwNjY2NyA1MDIyODUxODgyODAyMjA4IDY3OTIyMDAxNjE1MjU4NzU=