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

[add] Arr::flatter wrap methods params #643

Closed
wants to merge 1 commit into from
Closed
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
17 changes: 9 additions & 8 deletions src/Concerns/IncludeableData.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Spatie\LaravelData\Concerns;

use Closure;
use Illuminate\Support\Arr;
use Spatie\LaravelData\Support\PartialsParser;
use Spatie\LaravelData\Support\PartialTrees;

Expand All @@ -29,36 +30,36 @@ public function withPartialTrees(PartialTrees $partialTrees): static
return $this;
}

public function include(string ...$includes): static
public function include(string|array ...$includes): static
{
foreach ($includes as $include) {
foreach (Arr::flatten($includes) as $include) {
$this->_includes[$include] = true;
}

return $this;
}

public function exclude(string ...$excludes): static
public function exclude(string|array ...$excludes): static
{
foreach ($excludes as $exclude) {
foreach (Arr::flatten($excludes) as $exclude) {
$this->_excludes[$exclude] = true;
}

return $this;
}

public function only(string ...$only): static
public function only(string|array ...$only): static
{
foreach ($only as $onlyDefinition) {
foreach (Arr::flatten($only) as $onlyDefinition) {
$this->_only[$onlyDefinition] = true;
}

return $this;
}

public function except(string ...$except): static
public function except(string|array ...$except): static
{
foreach ($except as $exceptDefinition) {
foreach (Arr::flatten($except) as $exceptDefinition) {
$this->_except[$exceptDefinition] = true;
}

Expand Down
Loading