Fix testing as a result of changes in 34139bc

This commit is contained in:
Deon George
2021-07-02 10:03:36 +10:00
parent 6656fc3d3d
commit 9e1723a7af
5 changed files with 19 additions and 31 deletions

View File

@@ -23,7 +23,7 @@ trait NextKey
$model->id = self::NextId();
if (! $model->site_id)
$model->site_id = config('SITE')->id;
$model->site_id = config('SITE')->site_id;
});
static::saved(function($model)
@@ -33,21 +33,22 @@ trait NextKey
throw new \Exception('Missing record_id const for '.get_class($model));
try {
$mo = Module::where('name',$model::RECORD_ID)->firstOrFail();
$mo = Module::where('name',$model::RECORD_ID)
->where('site_id',$model->site_id)->firstOrFail();
} catch (ModelNotFoundException $e) {
Log::critical(sprintf('Module [%s] not recorded, we\'ll create it.',$model::RECORD_ID),['model'=>$model->getAttributes()]);
$mo = new Module;
$mo->name = $model::RECORD_ID;
$mo->site_id = $model->site_id ?: config('SITE')->id;
$mo->site_id = $model->site_id ?: config('SITE')->site_id;
$mo->save();
}
if (! $mo->record) {
$mo->record = new Record;
$mo->record->module_id = $mo->id;
$mo->record->site_id = $model->site_id ?: config('SITE')->id;
$mo->record->site_id = $model->site_id ?: config('SITE')->site_id;
}
$mo->record->id = $model->id;