Commit 442904b2 authored by Taylor Otwell's avatar Taylor Otwell

refactoring.

parent 5cc7c3a6
...@@ -61,7 +61,7 @@ class Redirect extends Response { ...@@ -61,7 +61,7 @@ class Redirect extends Response {
throw new \Exception('A session driver must be set before setting flash data.'); throw new \Exception('A session driver must be set before setting flash data.');
} }
IoC::container()->resolve('laravel.session')->flash($key, $value); IoC::container()->core('session')->flash($key, $value);
return $this; return $this;
} }
......
...@@ -119,17 +119,17 @@ class Request { ...@@ -119,17 +119,17 @@ class Request {
*/ */
public function ip($default = '0.0.0.0') public function ip($default = '0.0.0.0')
{ {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) if (isset($this->server['HTTP_X_FORWARDED_FOR']))
{ {
return $_SERVER['HTTP_X_FORWARDED_FOR']; return $this->server['HTTP_X_FORWARDED_FOR'];
} }
elseif (isset($_SERVER['HTTP_CLIENT_IP'])) elseif (isset($this->server['HTTP_CLIENT_IP']))
{ {
return $_SERVER['HTTP_CLIENT_IP']; return $this->server['HTTP_CLIENT_IP'];
} }
elseif (isset($_SERVER['REMOTE_ADDR'])) elseif (isset($this->server['REMOTE_ADDR']))
{ {
return $_SERVER['REMOTE_ADDR']; return $this->server['REMOTE_ADDR'];
} }
return ($default instanceof \Closure) ? call_user_func($default) : $default; return ($default instanceof \Closure) ? call_user_func($default) : $default;
......
...@@ -133,7 +133,7 @@ class Response { ...@@ -133,7 +133,7 @@ class Response {
*/ */
public static function view($view, $data = array()) public static function view($view, $data = array())
{ {
return new static(IoC::container()->resolve('laravel.view')->make($view, $data)); return new static(IoC::container()->core('view')->make($view, $data));
} }
/** /**
...@@ -153,7 +153,7 @@ class Response { ...@@ -153,7 +153,7 @@ class Response {
*/ */
public static function with($name, $data = array()) public static function with($name, $data = array())
{ {
return new static(IoC::container()->resolve('laravel.view')->of($name, $data)); return new static(IoC::container()->core('view')->of($name, $data));
} }
/** /**
...@@ -177,7 +177,7 @@ class Response { ...@@ -177,7 +177,7 @@ class Response {
*/ */
public static function error($code, $data = array()) public static function error($code, $data = array())
{ {
return new static(IoC::container()->resolve('laravel.view')->make('error/'.$code, $data), $code); return new static(IoC::container()->core('view')->make('error/'.$code, $data), $code);
} }
/** /**
...@@ -274,6 +274,7 @@ class Response { ...@@ -274,6 +274,7 @@ class Response {
public function header($name, $value) public function header($name, $value)
{ {
$this->headers[$name] = $value; $this->headers[$name] = $value;
return $this; return $this;
} }
...@@ -286,6 +287,7 @@ class Response { ...@@ -286,6 +287,7 @@ class Response {
public function status($status) public function status($status)
{ {
$this->status = $status; $this->status = $status;
return $this; return $this;
} }
......
...@@ -28,7 +28,7 @@ class Str { ...@@ -28,7 +28,7 @@ class Str {
{ {
if (function_exists('mb_strtoupper')) if (function_exists('mb_strtoupper'))
{ {
return mb_strtoupper($value, static::encoding()); return mb_strtoupper($value, Config::get('application.encoding'));
} }
return strtoupper($value); return strtoupper($value);
...@@ -84,19 +84,17 @@ class Str { ...@@ -84,19 +84,17 @@ class Str {
/** /**
* Generate a random alpha or alpha-numeric string. * Generate a random alpha or alpha-numeric string.
* *
* Supported types: 'alpha_num' and 'alpha'. * Supported types: 'alnum' and 'alpha'.
* *
* @param int $length * @param int $length
* @param string $type * @param string $type
* @return string * @return string
*/ */
public static function random($length = 16, $type = 'alpha_num') public static function random($length, $type = 'alnum')
{ {
$alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$pool = ($type == 'alpha_num') ? '0123456789'.$alpha : $alpha; return substr(str_shuffle(str_repeat(($type == 'alnum') ? $pool.'0123456789' : $pool, 5)), 0, $length);
return implode('', array_map(function() use ($pool) { return $pool[mt_rand(0, strlen($pool) - 1)]; }, range(0, $length - 1)));
} }
} }
\ No newline at end of file
...@@ -50,7 +50,7 @@ class URL { ...@@ -50,7 +50,7 @@ class URL {
*/ */
public static function to_asset($url, $https = null) public static function to_asset($url, $https = null)
{ {
if (is_null($https)) $https = IoC::container()->resolve('laravel.request')->secure(); if (is_null($https)) $https = IoC::container()->core('request')->secure();
return str_replace('index.php/', '', static::to($url, $https)); return str_replace('index.php/', '', static::to($url, $https));
} }
...@@ -77,7 +77,7 @@ class URL { ...@@ -77,7 +77,7 @@ class URL {
*/ */
public static function to_route($name, $parameters = array(), $https = false) public static function to_route($name, $parameters = array(), $https = false)
{ {
if ( ! is_null($route = IoC::container()->resolve('laravel.routing.router')->find($name))) if ( ! is_null($route = IoC::container()->core('routing.router')->find($name)))
{ {
$uris = explode(', ', key($route)); $uris = explode(', ', key($route));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment