* // Get the first segment of the request URI * $segment = URI::segment(1); * * // Get the second segment of the URI, or return a default value * $segment = URI::segment(2, 'Taylor'); * * * @param int $index * @param mixed $default * @return string */ public static function segment($index, $default = null) { static::current(); return Arr::get(static::$segments, $index - 1, $default); } /** * Remove a given value from the URI. * * @param string $uri * @param string $value * @return string */ protected static function remove($uri, $value) { if (strpos($uri, $value) === 0) { return substr($uri, strlen($value)); } return $uri; } /** * Format a given URI. * * If the URI is an empty string, a single forward slash will be returned. * Otherwise, we will simply trim the URI's leading and trailing slashes. * * @param string $uri * @return string */ protected static function format($uri) { return (($uri = trim($uri, '/')) !== '') ? $uri : '/'; } }