Merge branch 'master' of github.com:laravel/laravel
This commit is contained in:
12
laravel/cache/drivers/redis.php
vendored
12
laravel/cache/drivers/redis.php
vendored
@@ -87,5 +87,15 @@ class Redis extends Driver {
|
||||
{
|
||||
$this->redis->del($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the entire cache.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
$this->redis->flushdb();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,8 @@ class Connection {
|
||||
|
||||
if (isset(\Laravel\Database::$registrar[$this->driver()]))
|
||||
{
|
||||
return $this->grammar = \Laravel\Database::$registrar[$this->driver()]['query']();
|
||||
$resolver = \Laravel\Database::$registrar[$this->driver()]['query'];
|
||||
return $this->grammar = $resolver($this);
|
||||
}
|
||||
|
||||
switch ($this->driver())
|
||||
@@ -308,7 +309,7 @@ class Connection {
|
||||
*/
|
||||
protected function log($sql, $bindings, $start)
|
||||
{
|
||||
$time = number_format((microtime(true) - $start) * 1000, 2);
|
||||
$time = (microtime(true) - $start) * 1000;
|
||||
|
||||
Event::fire('laravel.query', array($sql, $bindings, $time));
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ Or, as usual, you may retrieve the relationship through the dynamic roles proper
|
||||
|
||||
$roles = User::find(1)->roles;
|
||||
|
||||
If your table names don't follow conventions, simply pass the table name in the second parameter to the **has\_and\_belongs\_to\_many** method:
|
||||
If your table names don't follow conventions, simply pass the table name in the second parameter to the **has\_many\_and\_belongs\_to** method:
|
||||
|
||||
class User extends Eloquent {
|
||||
|
||||
|
||||
@@ -76,6 +76,13 @@ There are a variety of methods to assist you in building where clauses. The most
|
||||
->or_where('email', '=', 'example@gmail.com')
|
||||
->first();
|
||||
|
||||
To do the equivalent of an AND where, simply chain the query with another where:
|
||||
|
||||
return DB::table('users')
|
||||
->where('id', '=', 1)
|
||||
->where('activated', '=', 1)
|
||||
->first();
|
||||
|
||||
Of course, you are not limited to simply checking equality. You may also use **greater-than**, **less-than**, **not-equal**, and **like**:
|
||||
|
||||
return DB::table('users')
|
||||
|
||||
@@ -83,6 +83,14 @@ Laravel provides an easy method of protecting your application from cross-site r
|
||||
|
||||
echo Form::label('email', 'E-Mail Address', array('class' => 'awesome'));
|
||||
|
||||
#### Turning off HTML escaping of label contents:
|
||||
|
||||
echo Form::label('confirm', 'Are you <strong>sure</strong> you want to proceed?', null, false);
|
||||
|
||||
You can pass ```false``` as the optional fourth argument to disable automatic HTML escaping of the label content.
|
||||
|
||||
|
||||
|
||||
> **Note:** After creating a label, any form element you create with a name matching the label name will automatically receive an ID matching the label name as well.
|
||||
|
||||
<a name="text"></a>
|
||||
|
||||
@@ -54,7 +54,7 @@ class Error {
|
||||
// Using events gives the developer more freedom.
|
||||
else
|
||||
{
|
||||
$response = Event::first('500');
|
||||
$response = Event::first('500', $exception);
|
||||
|
||||
$response = Response::prepare($response);
|
||||
}
|
||||
|
||||
@@ -182,13 +182,15 @@ class Form {
|
||||
* @param array $attributes
|
||||
* @return string
|
||||
*/
|
||||
public static function label($name, $value, $attributes = array())
|
||||
public static function label($name, $value, $attributes = array(), $escape_html = true)
|
||||
{
|
||||
static::$labels[] = $name;
|
||||
|
||||
$attributes = HTML::attributes($attributes);
|
||||
|
||||
$value = HTML::entities($value);
|
||||
if ($escape_html) {
|
||||
$value = HTML::entities($value);
|
||||
}
|
||||
|
||||
return '<label for="'.$name.'"'.$attributes.'>'.$value.'</label>';
|
||||
}
|
||||
|
||||
@@ -56,7 +56,31 @@ class Log {
|
||||
Event::fire('laravel.log', array($type, $message));
|
||||
}
|
||||
|
||||
$message = static::format($type, $message);
|
||||
$trace=debug_backtrace();
|
||||
|
||||
foreach($trace as $item)
|
||||
{
|
||||
if (isset($item['class']) AND $item['class'] == __CLASS__)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$caller = $item;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$function = $caller['function'];
|
||||
if (isset($caller['class']))
|
||||
{
|
||||
$class = $caller['class'] . '::';
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = '';
|
||||
}
|
||||
|
||||
$message = static::format($type, $class . $function . ' - ' . $message);
|
||||
|
||||
File::append(path('storage').'logs/'.date('Y-m-d').'.log', $message);
|
||||
}
|
||||
@@ -96,4 +120,4 @@ class Log {
|
||||
static::write($method, $parameters[0], $parameters[1]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
@foreach ($queries as $query)
|
||||
<tr>
|
||||
<td class="anbu-table-first">
|
||||
{{ $query[1] }}ms
|
||||
{{ number_format($query[1], 2) }}ms
|
||||
</td>
|
||||
<td>
|
||||
<pre>{{ $query[0] }}</pre>
|
||||
@@ -103,7 +103,7 @@
|
||||
<a data-anbu-tab="anbu-sql" class="anbu-tab" href="#">SQL
|
||||
<span class="anbu-count">{{ count($queries) }}</span>
|
||||
@if (count($queries))
|
||||
<span class="anbu-count">{{ array_sum(array_map(function($q) { return $q[1]; }, $queries)) }}ms</span>
|
||||
<span class="anbu-count">{{ number_format(array_sum(array_pluck($queries, '1')), 2) }}ms</span>
|
||||
@endif
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -16,6 +16,13 @@ class Redis {
|
||||
*/
|
||||
protected $port;
|
||||
|
||||
/**
|
||||
* The database password, if present.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $password;
|
||||
|
||||
/**
|
||||
* The database number the connection selects on load.
|
||||
*
|
||||
@@ -45,10 +52,11 @@ class Redis {
|
||||
* @param int $database
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($host, $port, $database = 0)
|
||||
public function __construct($host, $port, $password = null, $database = 0)
|
||||
{
|
||||
$this->host = $host;
|
||||
$this->port = $port;
|
||||
$this->password = $password;
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
@@ -79,7 +87,12 @@ class Redis {
|
||||
|
||||
extract($config);
|
||||
|
||||
static::$databases[$name] = new static($host, $port, $database);
|
||||
if ( ! isset($password))
|
||||
{
|
||||
$password = null;
|
||||
}
|
||||
|
||||
static::$databases[$name] = new static($host, $port, $password, $database);
|
||||
}
|
||||
|
||||
return static::$databases[$name];
|
||||
@@ -153,6 +166,11 @@ class Redis {
|
||||
throw new \Exception("Error making Redis connection: {$error} - {$message}");
|
||||
}
|
||||
|
||||
if ( $this->password )
|
||||
{
|
||||
$this->auth($this->password);
|
||||
}
|
||||
|
||||
$this->select($this->database);
|
||||
|
||||
return $this->connection;
|
||||
|
||||
@@ -196,7 +196,7 @@ class Request {
|
||||
*/
|
||||
public static function cli()
|
||||
{
|
||||
return defined('STDIN') || (substr(PHP_SAPI, 0, 3) == 'cgi' && getenv('TERM'));
|
||||
return defined('STDIN') || (PHP_SAPI != "cgi-fcgi" && substr(PHP_SAPI, 0, 3) == 'cgi' && getenv('TERM'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,4 +287,4 @@ class Request {
|
||||
return call_user_func_array(array(static::foundation(), $method), $parameters);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ abstract class Controller {
|
||||
// Again, as was the case with route closures, if the controller "before"
|
||||
// filters return a response, it will be considered the response to the
|
||||
// request and the controller method will not be used.
|
||||
$response = Filter::run($filters, array(), true);
|
||||
$response = Filter::run($filters, $parameters, true);
|
||||
|
||||
if (is_null($response))
|
||||
{
|
||||
@@ -439,4 +439,4 @@ abstract class Controller {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class Cookie extends Driver {
|
||||
|
||||
$payload = Crypter::encrypt(serialize($session));
|
||||
|
||||
C::put(Cookie::payload, $payload, $lifetime, $path, $domain);
|
||||
C::put(Cookie::payload, $payload, $lifetime, $path, $domain, $secure);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,4 +53,4 @@ class Cookie extends Driver {
|
||||
C::forget(Cookie::payload);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,9 +111,11 @@ class FormTest extends PHPUnit_Framework_TestCase {
|
||||
{
|
||||
$form1 = Form::label('foo', 'Foobar');
|
||||
$form2 = Form::label('foo', 'Foobar', array('class' => 'control-label'));
|
||||
$form3 = Form::label('foo', 'Foobar <i>baz</i>', null, false);
|
||||
|
||||
$this->assertEquals('<label for="foo">Foobar</label>', $form1);
|
||||
$this->assertEquals('<label for="foo" class="control-label">Foobar</label>', $form2);
|
||||
$this->assertEquals('<label for="foo">Foobar <i>baz</i></label>', $form3);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user