Showing 1 of 3 files from the diff.

@@ -16,33 +16,26 @@
Loading
16 16
17 17
trait LogsModelEvents
18 18
{
19 -
    protected static $dontLogUpdatedColumns = [
20 -
        'updated_at',
21 -
    ];
22 -
23 -
    protected static $sanitizeUpdatedColumns = [
24 -
        'password',
25 -
    ];
26 -
27 19
    // List of Laravel model events that should be recorded
28 20
    // public static $logModelEvents = ['created','updated'];
29 21
30 -
    public static function bootLogsModelEvents() {
22 +
    public static function bootLogsModelEvents()
23 +
    {
31 24
32 -
        if(property_exists(self::class,'logModelEvents')){
25 +
        if (property_exists(self::class, 'logModelEvents')) {
33 26
34 -
            foreach(self::$logModelEvents as $eventName){
27 +
            foreach (self::$logModelEvents as $eventName) {
35 28
36 -
                static::$eventName(function($model) use ($eventName){
29 +
                static::$eventName(function ($model) use ($eventName) {
37 30
                    $description = $eventName;
38 31
39 -
                    if($eventName == 'updating' || $eventName == 'updated'){
40 -
                        if($dirty = $model->getDirty()){
32 +
                    if ($eventName == 'updating' || $eventName == 'updated') {
33 +
                        if ($dirty = $model->getDirty()) {
41 34
42 -
                            $changed=[];
43 -
                            foreach($dirty as $key => $value){
44 -
                                if(!in_array($key, self::$dontLogUpdatedColumns)) {
45 -
                                    if(in_array($key, self::$sanitizeUpdatedColumns)) {
35 +
                            $changed = [];
36 +
                            foreach ($dirty as $key => $value) {
37 +
                                if (!self::shouldHideKey($key)) {
38 +
                                    if (self::shouldSanitizeKey($key)) {
46 39
                                        $changed[] = "'$key': ***";
47 40
                                    } else {
48 41
                                        $changed[] = "'$key': [" . ($model->original[$key] ?? '-') . "]→[$value]";
@@ -51,7 +44,7 @@
Loading
51 44
                            }
52 45
53 46
                            if ($changed) {
54 -
                                $description .= ':'. implode(', ', $changed);
47 +
                                $description .= ':' . implode(', ', $changed);
55 48
                            }
56 49
                        }
57 50
                    }
@@ -61,9 +54,19 @@
Loading
61 54
62 55
            }
63 56
        }
57 +
    }
64 58
59 +
    private static function shouldHideKey($key): bool
60 +
    {
61 +
        return isset(self::$dontLogUpdatedColumns) && in_array($key, self::$dontLogUpdatedColumns);
65 62
    }
66 63
64 +
    private static function shouldSanitizeKey($key): bool
65 +
    {
66 +
        return isset(self::$sanitizeUpdatedColumns) && in_array($key, self::$sanitizeUpdatedColumns);
67 +
    }
68 +
69 +
67 70
    // ----------------------------------------------
68 71
    //  Relationships
69 72
    // ----------------------------------------------
Files Complexity Coverage
src 36 66.40%
Project Totals (8 files) 36 66.40%
15.1
7.2=.2
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading