Skip to content

Commit

Permalink
Merge pull request #1473 from moonshine-software/is-now-on-sugar
Browse files Browse the repository at this point in the history
Is now on sugar
  • Loading branch information
lee-to authored Jan 15, 2025
2 parents 220750b + 36f945c commit d1842e4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Resources/CrudResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ public function getIndexPage(): ?PageContract
return $this->getPages()->indexPage();
}

public function isIndexPage(): bool
{
return $this->getActivePage() instanceof IndexPage;
}

/**
* @return null|PageContract<TFormPage>|FormPage
*/
Expand All @@ -155,6 +160,21 @@ public function getFormPage(): ?PageContract
return $this->getPages()->formPage();
}

public function isFormPage(): bool
{
return $this->getActivePage() instanceof FormPage;
}

public function isCreateFormPage(): bool
{
return $this->isFormPage() && \is_null($this->getItemID());
}

public function isUpdateFormPage(): bool
{
return $this->isFormPage() && ! \is_null($this->getItemID());
}

public function getActivePage(): ?PageContract
{
return $this->getPages()->activePage();
Expand All @@ -168,6 +188,11 @@ public function getDetailPage(): ?PageContract
return $this->getPages()->detailPage();
}

public function isDetailPage(): bool
{
return $this->getActivePage() instanceof DetailPage;
}

public function getCaster(): DataCasterContract
{
return new MixedDataCaster($this->casterKeyName);
Expand Down

0 comments on commit d1842e4

Please sign in to comment.