Get a fresh copy of the model to display after create/update to ensure consistency
This commit is contained in:
parent
7785241e12
commit
228ea6eacc
|
|
@ -308,4 +308,14 @@ trait SavesData
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a fresh copy of the model for display.
|
||||
*/
|
||||
private function freshModel(ResourceType $resourceType, $model, Context $context)
|
||||
{
|
||||
$id = $resourceType->getAdapter()->getId($model);
|
||||
|
||||
return $this->findResource($resourceType, $id, $context);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ class Create
|
|||
|
||||
run_callbacks($schema->getListeners('created'), [&$model, $context]);
|
||||
|
||||
$model = $this->freshModel($resourceType, $model, $context);
|
||||
|
||||
return (new Show())
|
||||
->handle($context, $resourceType, $model)
|
||||
->withStatus(201)
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ class Update
|
|||
|
||||
run_callbacks($schema->getListeners('updated'), [&$model, $context]);
|
||||
|
||||
$model = $this->freshModel($resourceType, $model, $context);
|
||||
|
||||
return (new Show())
|
||||
->handle($context, $resourceType, $model);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue