@@ -49,7 +49,7 @@ public function user()
49
49
{
50
50
$ morphPrefix = Config::get ('audit.user.morph_prefix ' , 'user ' );
51
51
52
- return $ this ->morphTo (__FUNCTION__ , $ morphPrefix . '_type ' , $ morphPrefix . '_id ' );
52
+ return $ this ->morphTo (__FUNCTION__ , $ morphPrefix. '_type ' , $ morphPrefix. '_id ' );
53
53
}
54
54
55
55
/**
@@ -77,37 +77,37 @@ public function resolveData(): array
77
77
78
78
// Metadata
79
79
$ this ->data = [
80
- 'audit_id ' => $ this ->getKey (),
81
- 'audit_event ' => $ this ->event ,
82
- 'audit_tags ' => $ this ->tags ,
80
+ 'audit_id ' => $ this ->getKey (),
81
+ 'audit_event ' => $ this ->event ,
82
+ 'audit_tags ' => $ this ->tags ,
83
83
'audit_created_at ' => $ this ->serializeDate ($ this ->{$ this ->getCreatedAtColumn ()}),
84
84
'audit_updated_at ' => $ this ->serializeDate ($ this ->{$ this ->getUpdatedAtColumn ()}),
85
- 'user_id ' => $ this ->getAttribute ($ morphPrefix . '_id ' ),
86
- 'user_type ' => $ this ->getAttribute ($ morphPrefix . '_type ' ),
85
+ 'user_id ' => $ this ->getAttribute ($ morphPrefix. '_id ' ),
86
+ 'user_type ' => $ this ->getAttribute ($ morphPrefix. '_type ' ),
87
87
];
88
88
89
89
// add resolvers data to metadata
90
90
$ resolverData = [];
91
91
foreach (array_keys (Config::get ('audit.resolvers ' , [])) as $ name ) {
92
- $ resolverData ['audit_ ' . $ name ] = $ this ->$ name ;
92
+ $ resolverData ['audit_ ' . $ name ] = $ this ->$ name ;
93
93
}
94
94
$ this ->data = array_merge ($ this ->data , $ resolverData );
95
95
96
96
if ($ this ->user ) {
97
97
foreach ($ this ->user ->getArrayableAttributes () as $ attribute => $ value ) {
98
- $ this ->data ['user_ ' . $ attribute ] = $ value ;
98
+ $ this ->data ['user_ ' . $ attribute ] = $ value ;
99
99
}
100
100
}
101
101
102
102
$ this ->metadata = array_keys ($ this ->data );
103
103
104
104
// Modified Auditable attributes
105
105
foreach ($ this ->new_values ?? [] as $ key => $ value ) {
106
- $ this ->data ['new_ ' . $ key ] = $ value ;
106
+ $ this ->data ['new_ ' . $ key ] = $ value ;
107
107
}
108
108
109
109
foreach ($ this ->old_values ?? [] as $ key => $ value ) {
110
- $ this ->data ['old_ ' . $ key ] = $ value ;
110
+ $ this ->data ['old_ ' . $ key ] = $ value ;
111
111
}
112
112
113
113
$ this ->modified = array_diff_key (array_keys ($ this ->data ), $ this ->metadata );
@@ -118,8 +118,7 @@ public function resolveData(): array
118
118
/**
119
119
* Get the formatted value of an Eloquent model.
120
120
*
121
- * @param mixed $value
122
- *
121
+ * @param mixed $value
123
122
* @return mixed
124
123
*/
125
124
protected function getFormattedValue (Model $ model , string $ key , $ value )
@@ -139,12 +138,13 @@ protected function getFormattedValue(Model $model, string $key, $value)
139
138
$ model ->getCasts ()
140
139
) && $ model ->getCasts ()[$ key ] == 'Illuminate\Database\Eloquent\Casts\AsArrayObject ' ) {
141
140
$ arrayObject = new \Illuminate \Database \Eloquent \Casts \ArrayObject (json_decode ($ value , true ) ?: []);
141
+
142
142
return $ arrayObject ;
143
143
}
144
144
145
145
// Cast to native PHP type
146
146
if ($ model ->hasCast ($ key )) {
147
- if ($ model ->getCastType ($ key ) == 'datetime ' ) {
147
+ if ($ model ->getCastType ($ key ) == 'datetime ' ) {
148
148
$ value = $ this ->castDatetimeUTC ($ model , $ value );
149
149
}
150
150
@@ -168,7 +168,7 @@ protected function getFormattedValue(Model $model, string $key, $value)
168
168
*/
169
169
private function castDatetimeUTC ($ model , $ value )
170
170
{
171
- if (!is_string ($ value )) {
171
+ if (! is_string ($ value )) {
172
172
return $ value ;
173
173
}
174
174
@@ -198,7 +198,7 @@ private function castDatetimeUTC($model, $value)
198
198
*/
199
199
public function getDataValue (string $ key )
200
200
{
201
- if (!array_key_exists ($ key , $ this ->data )) {
201
+ if (! array_key_exists ($ key , $ this ->data )) {
202
202
return ;
203
203
}
204
204
@@ -226,15 +226,14 @@ public function getDataValue(string $key)
226
226
/**
227
227
* Decode attribute value.
228
228
*
229
- * @param mixed $value
230
- *
229
+ * @param mixed $value
231
230
* @return mixed
232
231
*/
233
232
protected function decodeAttributeValue (Contracts \Auditable $ auditable , string $ attribute , $ value )
234
233
{
235
234
$ attributeModifiers = $ auditable ->getAttributeModifiers ();
236
235
237
- if (!array_key_exists ($ attribute , $ attributeModifiers )) {
236
+ if (! array_key_exists ($ attribute , $ attributeModifiers )) {
238
237
return $ value ;
239
238
}
240
239
@@ -263,7 +262,7 @@ public function getMetadata(bool $json = false, int $options = 0, int $depth = 5
263
262
$ metadata [$ key ] = $ value ;
264
263
265
264
if ($ value instanceof DateTimeInterface) {
266
- $ metadata [$ key ] = !is_null ($ this ->auditable ) ? $ this ->auditable ->serializeDate ($ value ) : $ this ->serializeDate ($ value );
265
+ $ metadata [$ key ] = ! is_null ($ this ->auditable ) ? $ this ->auditable ->serializeDate ($ value ) : $ this ->serializeDate ($ value );
267
266
}
268
267
}
269
268
@@ -293,11 +292,10 @@ public function getModified(bool $json = false, int $options = 0, int $depth = 5
293
292
$ modified [$ attribute ][$ state ] = $ value ;
294
293
295
294
if ($ value instanceof DateTimeInterface) {
296
- $ modified [$ attribute ][$ state ] = !is_null ($ this ->auditable ) ? $ this ->auditable ->serializeDate ($ value ) : $ this ->serializeDate ($ value );
295
+ $ modified [$ attribute ][$ state ] = ! is_null ($ this ->auditable ) ? $ this ->auditable ->serializeDate ($ value ) : $ this ->serializeDate ($ value );
297
296
}
298
297
}
299
298
300
-
301
299
if (! $ json ) {
302
300
return $ modified ;
303
301
}
@@ -312,6 +310,6 @@ public function getModified(bool $json = false, int $options = 0, int $depth = 5
312
310
*/
313
311
public function getTags (): array
314
312
{
315
- return preg_split ('/,/ ' , $ this ->tags , -1 , PREG_SPLIT_NO_EMPTY )?: [];
313
+ return preg_split ('/,/ ' , $ this ->tags , -1 , PREG_SPLIT_NO_EMPTY ) ?: [];
316
314
}
317
315
}
0 commit comments