Skip to content

Commit 47ce2a8

Browse files
committed
Improvement: storing model properties at creation time in trait Logable
1 parent 18c3018 commit 47ce2a8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Models/Logable.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/**
66
* Trait Logable
77
* @package Thiagoprz\EasyCrud\Models
8+
* @extends \Illuminate\Database\Eloquent\Model
89
*/
910
trait Logable
1011
{
@@ -37,11 +38,14 @@ public static function bootLogable()
3738
}
3839

3940
/**
40-
* @param $model
41+
* @param \Illuminate\Database\Eloquent\Model $model
4142
*/
4243
private static function getAttributesFiltered($model)
4344
{
4445
$attributes = $model->getOriginal();
46+
if (empty($attributes)) { // may be empty on created() event
47+
$attributes = $model->getAttributes();
48+
}
4549
if (!empty($model->hidden)) {
4650
$hidden = $model->hidden;
4751
$attributes = array_filter($attributes, function($attr, $field) use($hidden) {

0 commit comments

Comments
 (0)