Skip to content

Commit 345f0ed

Browse files
committed
Improve attributes
1 parent 557a715 commit 345f0ed

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Lodash/Testing/Attributes.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Longman\LaravelLodash\Testing;
66

77
use Illuminate\Contracts\Support\Arrayable;
8+
use Illuminate\Support\Arr;
89
use InvalidArgumentException;
910

1011
use function array_key_exists;
@@ -31,9 +32,11 @@ public function __construct(array $params, string $relationName = 'root', int $c
3132
$this->parseParameters($params);
3233
}
3334

34-
public function getAttributes(array $extraAttrs = []): array
35+
public function getAttributes(array $extraAttrs = [], array $except = []): array
3536
{
36-
return array_replace_recursive($this->attributes, $extraAttrs);
37+
$array = array_replace_recursive($this->attributes, $extraAttrs);
38+
39+
return Arr::except($array, $except);
3740
}
3841

3942
public function hasAttribute(string $name): bool
@@ -88,9 +91,11 @@ public function addRelation(string $name, int $count = 1, array $data = []): voi
8891
$this->params = array_replace_recursive($this->params, [self::RELATION_MARKER . $name . ':' . $count => $data]);
8992
}
9093

91-
public function toArray(array $extraParams = []): array
94+
public function toArray(array $extraParams = [], array $except = []): array
9295
{
93-
return array_replace_recursive($this->params, $extraParams);
96+
$array = array_replace_recursive($this->params, $extraParams);
97+
98+
return Arr::except($array, $except);
9499
}
95100

96101
private function parseParameters(array $params): void

0 commit comments

Comments
 (0)