Changed ezypay matching to use referenceid, fixed NextKey for existing records

This commit is contained in:
Deon George
2019-06-07 22:34:41 +10:00
parent 253eb55c19
commit 78d55fb423
2 changed files with 19 additions and 15 deletions

View File

@@ -22,12 +22,14 @@ trait NextKey
static::saved(function($model)
{
if (! $model::RECORD_ID)
throw new \Exception('Missing record_id const for '.get_class($model));
if ($model->wasRecentlyCreated) {
if (! defined(get_class($model).'::RECORD_ID'))
throw new \Exception('Missing record_id const for '.get_class($model));
$mo = Module::where('name',$model::RECORD_ID)->firstOrFail();
$mo->record->id = $model->id;
$mo->record->save();
$mo = Module::where('name',$model::RECORD_ID)->firstOrFail();
$mo->record->id = $model->id;
$mo->record->save();
}
});
}