Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
@@ -218,9 +218,11 @@ abstract class Model {
|
||||
{
|
||||
$model = new static(array(), true);
|
||||
|
||||
if (static::$timestamps) $attributes['updated_at'] = new \DateTime;
|
||||
$model->fill($attributes);
|
||||
|
||||
return $model->query()->where($model->key(), '=', $id)->update($attributes);
|
||||
if (static::$timestamps) $model->timestamp();
|
||||
|
||||
return $model->query()->where($model->key(), '=', $id)->update($model->attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -500,7 +502,7 @@ abstract class Model {
|
||||
*/
|
||||
public function changed($attribute)
|
||||
{
|
||||
return array_get($this->attributes, $attribute) !== array_get($this->original, $attribute);
|
||||
return array_get($this->attributes, $attribute) != array_get($this->original, $attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -536,7 +538,7 @@ abstract class Model {
|
||||
|
||||
foreach ($this->attributes as $key => $value)
|
||||
{
|
||||
if ( ! isset($this->original[$key]) or $value !== $this->original[$key])
|
||||
if ( ! array_key_exists($key, $this->original) or $value !== $this->original[$key])
|
||||
{
|
||||
$dirty[$key] = $value;
|
||||
}
|
||||
@@ -725,7 +727,7 @@ abstract class Model {
|
||||
{
|
||||
foreach (array('attributes', 'relationships') as $source)
|
||||
{
|
||||
if (array_key_exists($key, $this->$source)) return true;
|
||||
if (array_key_exists($key, $this->$source)) return !is_null($this->$source[$key]);
|
||||
}
|
||||
|
||||
if (method_exists($this, $key)) return true;
|
||||
|
||||
@@ -140,7 +140,7 @@ class Query {
|
||||
*/
|
||||
public function select($columns = array('*'))
|
||||
{
|
||||
$this->selects = (array) $columns;
|
||||
$this->selects = is_array($columns) ? $columns : array($columns);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ class Query {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a nested where condition to the query.
|
||||
* Add nested constraints to the query.
|
||||
*
|
||||
* @param Closure $callback
|
||||
* @param string $connector
|
||||
@@ -403,24 +403,7 @@ class Query {
|
||||
*/
|
||||
public function where_nested($callback, $connector = 'AND')
|
||||
{
|
||||
$type = 'where_nested';
|
||||
|
||||
// To handle a nested where statement, we will actually instantiate a new
|
||||
// Query instance and run the callback over that instance, which will
|
||||
// allow the developer to have a fresh query instance
|
||||
$query = new Query($this->connection, $this->grammar, $this->from);
|
||||
|
||||
call_user_func($callback, $query);
|
||||
|
||||
// Once the callback has been run on the query, we will store the nested
|
||||
// query instance on the where clause array so that it's passed to the
|
||||
// query's query grammar instance when building.
|
||||
if ($query->wheres !== null)
|
||||
{
|
||||
$this->wheres[] = compact('type', 'query', 'connector');
|
||||
}
|
||||
|
||||
$this->bindings = array_merge($this->bindings, $query->bindings);
|
||||
call_user_func($callback, $this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ class MySQL extends Grammar {
|
||||
*/
|
||||
protected function unsigned(Table $table, Fluent $column)
|
||||
{
|
||||
if ($column->type == 'integer' && $column->unsigned)
|
||||
if ($column->type == 'integer' && ($column->unsigned || $column->increment))
|
||||
{
|
||||
return ' UNSIGNED';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user