refactoring.
This commit is contained in:
parent
5cc7c3a6bd
commit
442904b277
|
@ -61,7 +61,7 @@ public function with($key, $value)
|
||||||
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 @@ public function spoofed()
|
||||||
*/
|
*/
|
||||||
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 @@ public static function make($content, $status = 200, $headers = array())
|
||||||
*/
|
*/
|
||||||
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 @@ public static function view($view, $data = array())
|
||||||
*/
|
*/
|
||||||
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 @@ public static function with($name, $data = array())
|
||||||
*/
|
*/
|
||||||
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 @@ public function send_headers()
|
||||||
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 @@ public function header($name, $value)
|
||||||
public function status($status)
|
public function status($status)
|
||||||
{
|
{
|
||||||
$this->status = $status;
|
$this->status = $status;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ public static function upper($value)
|
||||||
{
|
{
|
||||||
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 @@ public static function ascii($value)
|
||||||
/**
|
/**
|
||||||
* 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)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -50,7 +50,7 @@ public static function to_secure($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 @@ public static function to_asset($url, $https = null)
|
||||||
*/
|
*/
|
||||||
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));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue