Created
May 13, 2020 12:20
-
-
Save reachkamrul/8053d7e5e61d006650f42d0e96f6a09d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('ninja_tables_item_attributes', function ($attributes) { | |
$latest = ninja_tables_DbTable()->where('table_id', $attributes['table_id'])->orderBy('id', 'DESC')->limit(1)->first(); | |
$value = json_decode($attributes['value'], true); | |
if ($latest) { | |
$latest = json_decode($latest->value, true); | |
if (isset($latest['id']) && isset($value['id'])) { | |
$value['id'] = $latest['id'] + 1; | |
} | |
} else { | |
$value['id'] = 1; | |
} | |
$attributes['value'] = json_encode($value); | |
return $attributes; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment