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

fixes passing string arguments to tab/section visibility methods #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vmcvlad
Copy link
Member

@vmcvlad vmcvlad commented Sep 12, 2023

No description provided.

@@ -230,15 +230,15 @@ public function labels(bool $labels): self

public function sectionVisibility($fields, bool $hidden): self
{
Collection::wrap(is_string($fields) ? func_get_args() : $fields)
Copy link
Member Author

@vmcvlad vmcvlad Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if $fields is a string, func_get_args() returns an array containing [$fields, $hidden]

->each(fn ($field) => $this->section($field)->put('hidden', $hidden));

return $this;
}

public function tabVisibility($tabs, bool $hidden): self
{
$tabs = Collection::wrap(is_string($tabs) ? func_get_args() : $tabs);
$tabs = Collection::wrap(is_string($tabs) ? [$tabs] : $tabs);

$this->template->get('sections')->each(fn ($section) => $tabs->when(
$tabs->contains($section->get('tab')),
Copy link
Member Author

@vmcvlad vmcvlad Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a collection contains true, the ->contains() method will always return true since that's how php works when doing loose comparisons ( see above comment and below picture )

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant