From 2526b28c39c1dea4aff3e8c1fa643740c049ec45 Mon Sep 17 00:00:00 2001 From: Dave L Date: Mon, 30 Mar 2026 13:49:40 -0700 Subject: [PATCH 1/3] Enhance guide with fresh and refresh method details Added sections for 'fresh' and 'refresh' methods to the working with entities guide. --- guide/getting-started/working-with-entities.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/guide/getting-started/working-with-entities.md b/guide/getting-started/working-with-entities.md index 3f9a125..17fd95e 100644 --- a/guide/getting-started/working-with-entities.md +++ b/guide/getting-started/working-with-entities.md @@ -31,3 +31,21 @@ Clones an entity and return an exact copy of the entity. This returned object is var user = getInstance( "User" ); var clonedUser = user.clone(); ``` + +## fresh + +Retrieves a new entity from the database with the same key value as the current entity. + +```javascript +var user = getInstance( "User" ); +var freshUser = user.fresh(); +``` + +## refresh + +Refreshes the attributes data for the entity with data from the database. + +```javascript +var user = getInstance( "User" ); +var refreshedUser = user.refresh(); +``` From c90b537069028a1a9c152c1ba67ce9d2e2d6b8e2 Mon Sep 17 00:00:00 2001 From: Dave L Date: Mon, 30 Mar 2026 13:53:18 -0700 Subject: [PATCH 2/3] Update guide/getting-started/working-with-entities.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- guide/getting-started/working-with-entities.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/guide/getting-started/working-with-entities.md b/guide/getting-started/working-with-entities.md index 17fd95e..a15861c 100644 --- a/guide/getting-started/working-with-entities.md +++ b/guide/getting-started/working-with-entities.md @@ -34,10 +34,13 @@ var clonedUser = user.clone(); ## fresh -Retrieves a new entity from the database with the same key value as the current entity. +Retrieves a new entity from the database with the same key value as the current entity. The current entity must be loaded (or otherwise have a primary key value), and calling `fresh()` executes a database query to retrieve the latest state. ```javascript -var user = getInstance( "User" ); +// Load an existing user record (throws if not found) +var user = getInstance( "User" ).findOrFail( 123 ); + +// Retrieve a fresh copy from the database (executes a DB query) var freshUser = user.fresh(); ``` From ac18fbc39a1ab2e1cefeb2f464574ff847f0e627 Mon Sep 17 00:00:00 2001 From: Dave L Date: Mon, 30 Mar 2026 13:58:49 -0700 Subject: [PATCH 3/3] Update user instance retrieval to use findOrFail --- guide/getting-started/working-with-entities.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/getting-started/working-with-entities.md b/guide/getting-started/working-with-entities.md index a15861c..53baee1 100644 --- a/guide/getting-started/working-with-entities.md +++ b/guide/getting-started/working-with-entities.md @@ -49,6 +49,6 @@ var freshUser = user.fresh(); Refreshes the attributes data for the entity with data from the database. ```javascript -var user = getInstance( "User" ); +var user = getInstance( "User" ).findOrFail( 123 ); var refreshedUser = user.refresh(); ```