Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Add fresh method to Blueprint & Fieldset classes #11066

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Fields/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/Fields/Fieldset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading