Skip to content

Commit

Permalink
Improvement: storing model properties at creation time in trait Logable
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoprz committed Nov 10, 2021
1 parent 18c3018 commit 47ce2a8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Models/Logable.php
Expand Up @@ -5,6 +5,7 @@
/**
* Trait Logable
* @package Thiagoprz\EasyCrud\Models
* @extends \Illuminate\Database\Eloquent\Model
*/
trait Logable
{
Expand Down Expand Up @@ -37,11 +38,14 @@ public static function bootLogable()
}

/**
* @param $model
* @param \Illuminate\Database\Eloquent\Model $model
*/
private static function getAttributesFiltered($model)
{
$attributes = $model->getOriginal();
if (empty($attributes)) { // may be empty on created() event
$attributes = $model->getAttributes();
}
if (!empty($model->hidden)) {
$hidden = $model->hidden;
$attributes = array_filter($attributes, function($attr, $field) use($hidden) {
Expand Down

0 comments on commit 47ce2a8

Please sign in to comment.