/** * @param string $name * @param mixed $default * * @return mixed */ public function payload($name, $default = null) { if (!static::$payload) { static::$payload = json_decode(file_get_contents('php://input'), true); } $parsed = explode('.', $name); $result = static::$payload; while ($parsed) { $next = array_shift($parsed); $next_crypted = Crypt::request($next); if (isset($result[$next])) { $result = $result[$next]; } elseif ($next_crypted != $next && isset($result[$next_crypted])) { $result = $result[$next_crypted]; } else { return $default; } } return $result; }
public static function body($setBody = null) { if ($setBody) { static::$payload = [$setBody]; } return Filter::with('core.response.body', is_array(static::$payload) ? implode('', static::$payload) : static::$payload); }