From 489fa62c60b1cf9b844b9791a3bd5dab94ffe5ed Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 6 Nov 2024 11:47:10 +0000 Subject: [PATCH 1/2] Add `fresh` method to `Blueprint` --- src/Fields/Blueprint.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Fields/Blueprint.php b/src/Fields/Blueprint.php index 2717299a08..f084b106c3 100644 --- a/src/Fields/Blueprint.php +++ b/src/Fields/Blueprint.php @@ -130,6 +130,19 @@ public function path() ])); } + public function fullyQualifiedHandle(): string + { + $handle = $this->handle(); + + if ($this->namespace()) { + $handle = $this->isNamespaced() + ? $this->namespace().'::'.$handle + : $this->namespace().'.'.$handle; + } + + return $handle; + } + public function setContents(array $contents) { $this->contents = $contents; @@ -517,6 +530,11 @@ public function reset() return true; } + public function fresh() + { + return BlueprintRepository::find($this->fullyQualifiedHandle()); + } + public function ensureField($handle, $fieldConfig, $tab = null, $prepend = false) { return $this->ensureFieldInTab($handle, $fieldConfig, $tab, $prepend); From e55c8c9ad5f7d81d8b1b9fa04a3764cfc76ba9d4 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 6 Nov 2024 11:48:47 +0000 Subject: [PATCH 2/2] Add `fresh` method to `Fieldset` --- src/Fields/Fieldset.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Fields/Fieldset.php b/src/Fields/Fieldset.php index 98bfbb16aa..d01f3c26d0 100644 --- a/src/Fields/Fieldset.php +++ b/src/Fields/Fieldset.php @@ -291,6 +291,11 @@ public function reset() return true; } + public function fresh() + { + return Facades\Fieldset::find($this->handle()); + } + public static function __callStatic($method, $parameters) { return Facades\Fieldset::{$method}(...$parameters);