Skip to content

Commit

Permalink
addHashableAttribute -> addHashable
Browse files Browse the repository at this point in the history
Following pattern from addFillable()
Tidy up code
  • Loading branch information
daftspunk committed Oct 18, 2016
1 parent c420ed0 commit 5790fec
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
13 changes: 12 additions & 1 deletion src/Database/Traits/Hashable.php
Expand Up @@ -45,7 +45,7 @@ public static function bootHashable()
* @param array|string|null $attributes
* @return $this
*/
public function addHashableAttribute($attributes = null)
public function addHashable($attributes = null)
{
$attributes = is_array($attributes) ? $attributes : func_get_args();

Expand Down Expand Up @@ -105,4 +105,15 @@ public function getOriginalHashValue($attribute)
? $this->originalHashableValues[$attribute]
: null;
}

/**
* @deprecated use self::addHashable()
* Remove this method if year >= 2018
*/
public function addHashableAttribute($attribute)
{
traceLog('The addHashableAttribute() method is deprecated, use addHashable() instead.');

return $this->addHashable($attribute);
}
}
21 changes: 19 additions & 2 deletions src/Database/Traits/Nullable.php
Expand Up @@ -4,6 +4,11 @@

trait Nullable
{
/**
* @var array List of attribute names which should be set to null when empty.
*
* protected $nullable = [];
*/

/**
* Boot the nullable trait for a model
Expand All @@ -25,9 +30,22 @@ public static function bootNullable()
});
}

/**
* Adds an attribute to the nullable attributes list
* @param array|string|null $attributes
* @return $this
*/
public function addNullable($attributes = null)
{
$attributes = is_array($attributes) ? $attributes : func_get_args();

$this->nullable = array_merge($this->nullable, $attributes);

return $this;
}

/**
* Nullify empty fields
*
* @return void
*/
public function nullableBeforeSave()
Expand All @@ -43,5 +61,4 @@ public function nullableBeforeSave()
}
}
}

}
2 changes: 1 addition & 1 deletion src/Database/Traits/Purgeable.php
Expand Up @@ -41,7 +41,7 @@ public static function bootPurgeable()
* @param array|string|null $attributes
* @return $this
*/
public function addPurgeableAttribute($attributes = null)
public function addPurgeable($attributes = null)
{
$attributes = is_array($attributes) ? $attributes : func_get_args();

Expand Down

0 comments on commit 5790fec

Please sign in to comment.