55namespace Longman \LaravelLodash \Testing ;
66
77use Illuminate \Contracts \Support \Arrayable ;
8+ use Illuminate \Support \Arr ;
89use InvalidArgumentException ;
910
1011use 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