Skip to content

Commit

Permalink
Restores addVisible
Browse files Browse the repository at this point in the history
  • Loading branch information
samgeorges committed Oct 27, 2022
1 parent 91e1bcc commit 58b50c9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
17 changes: 14 additions & 3 deletions src/Database/Concerns/HasAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,25 @@ public function addDateAttribute($attribute)

/**
* addFillable attributes for the model.
*
* @param array|string|null $attributes
* @return void
*/
public function addFillable($attributes = null)
{
$attributes = is_array($attributes) ? $attributes : func_get_args();
$this->fillable = array_merge(
$this->fillable, is_array($attributes) ? $attributes : func_get_args()
);
}

$this->fillable = array_merge($this->fillable, $attributes);
/**
* addVisible attributes for the model.
* @param array|string|null $attributes
* @return void
*/
public function addVisible($attributes = null)
{
$this->visible = array_merge(
$this->visible, is_array($attributes) ? $attributes : func_get_args()
);
}
}
12 changes: 6 additions & 6 deletions src/Database/Traits/Hashable.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function initializeHashable()
}

/**
* Adds an attribute to the hashable attributes list
* addHashable adds an attribute to the hashable attributes list
* @param array|string|null $attributes
* @return $this
*/
Expand All @@ -58,7 +58,7 @@ public function addHashable($attributes = null)
}

/**
* Hashes an attribute value and saves it in the original locker.
* makeHashValue hashes an attribute value and saves it in the original locker.
* @param string $key Attribute
* @param string $value Value to hash
* @return string Hashed value
Expand All @@ -70,7 +70,7 @@ public function makeHashValue($key, $value)
}

/**
* Checks if the supplied plain value matches the stored hash value.
* checkHashValue checks if the supplied plain value matches the stored hash value.
* @param string $key Attribute to check
* @param string $value Value to check
* @return bool
Expand All @@ -81,7 +81,7 @@ public function checkHashValue($key, $value)
}

/**
* Returns a collection of fields that will be hashed.
* getHashableAttributes returns a collection of fields that will be hashed.
* @return array
*/
public function getHashableAttributes()
Expand All @@ -90,7 +90,7 @@ public function getHashableAttributes()
}

/**
* Returns the original values of any hashed attributes.
* getOriginalHashValues returns the original values of any hashed attributes.
* @return array
*/
public function getOriginalHashValues()
Expand All @@ -99,7 +99,7 @@ public function getOriginalHashValues()
}

/**
* Returns the original values of any hashed attributes.
* getOriginalHashValue returns the original values of any hashed attributes.
* @return mixed
*/
public function getOriginalHashValue($attribute)
Expand Down
16 changes: 8 additions & 8 deletions src/Database/Traits/Purgeable.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
trait Purgeable
{
/**
* @var array List of attribute names which should not be saved to the database.
* @var array purgeable attribute names which should not be saved to the database.
*
* protected $purgeable = [];
*/

/**
* @var array List of original attribute values before they were purged.
* @var array originalPurgeableValues before they were purged.
*/
protected $originalPurgeableValues = [];

Expand All @@ -40,7 +40,7 @@ public function initializePurgeable()
}

/**
* Adds an attribute to the purgeable attributes list
* addPurgeable adds an attribute to the purgeable attributes list
* @param array|string|null $attributes
* @return void
*/
Expand All @@ -52,7 +52,7 @@ public function addPurgeable($attributes = null)
}

/**
* Removes purged attributes from the dataset, used before saving.
* purgeAttributes removes purged attributes from the dataset, used before saving.
* @param $attributes mixed Attribute(s) to purge, if unspecified, $purgable property is used
* @return array Current attribute set
*/
Expand Down Expand Up @@ -80,31 +80,31 @@ public function purgeAttributes($attributesToPurge = null)
}

/**
* Returns a collection of fields that will be hashed.
* getPurgeableAttributes returns a collection of fields that will be hashed.
*/
public function getPurgeableAttributes()
{
return $this->purgeable;
}

/**
* Returns the original values of any purged attributes.
* getOriginalPurgeValues returns the original values of any purged attributes.
*/
public function getOriginalPurgeValues()
{
return $this->originalPurgeableValues;
}

/**
* Returns the original values of any purged attributes.
* getOriginalPurgeValue returns the original values of any purged attributes.
*/
public function getOriginalPurgeValue($attribute)
{
return $this->originalPurgeableValues[$attribute] ?? null;
}

/**
* Restores the original values of any purged attributes.
* restorePurgedValues restores the original values of any purged attributes.
*/
public function restorePurgedValues()
{
Expand Down

0 comments on commit 58b50c9

Please sign in to comment.