Skip to content

Commit da69f8f

Browse files
committed
feat!: don't refresh the model after create/update
In some cases you want to be able to create a model without persisting it, and then show it immediately.
1 parent a596448 commit da69f8f

File tree

3 files changed

+0
-14
lines changed

3 files changed

+0
-14
lines changed

src/Endpoint/Concerns/SavesData.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,4 @@ private function runSavedCallbacks(ResourceType $resourceType, array $data, $mod
308308
);
309309
}
310310
}
311-
312-
/**
313-
* Get a fresh copy of the model for display.
314-
*/
315-
private function freshModel(ResourceType $resourceType, $model, Context $context)
316-
{
317-
$id = $resourceType->getAdapter()->getId($model);
318-
319-
return $this->findResource($resourceType, $id, $context);
320-
}
321311
}

src/Endpoint/Create.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ public function handle(Context $context, ResourceType $resourceType): ResponseIn
5656

5757
run_callbacks($schema->getListeners('created'), [&$model, $context]);
5858

59-
$model = $this->freshModel($resourceType, $model, $context);
60-
6159
return (new Show())
6260
->handle($context, $resourceType, $model)
6361
->withStatus(201)

src/Endpoint/Update.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ public function handle(Context $context, ResourceType $resourceType, $model): Re
5353

5454
run_callbacks($schema->getListeners('updated'), [&$model, $context]);
5555

56-
$model = $this->freshModel($resourceType, $model, $context);
57-
5856
return (new Show())
5957
->handle($context, $resourceType, $model);
6058
}

0 commit comments

Comments
 (0)