Skip to content

Commit 39035ec

Browse files
author
Marius
committed
bulletproofing forceReplace and forceOffsetUnset macros
1 parent 16a17cb commit 39035ec

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

src/Providers/CrudProvider.php

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,19 @@ function (...$arguments): Model {
4242
Request::macro('forceOffsetUnset', function (string $offset): Request {
4343
/** @var Request $this */
4444

45-
if ($this->json()->has($offset)) {
46-
$this->json()->remove($offset);
47-
}
48-
49-
if ($this->query->has($offset)) {
50-
$this->query->remove($offset);
51-
}
52-
53-
if ($this->request->has($offset)) {
54-
$this->request->remove($offset);
55-
}
45+
$this->query->remove($offset);
46+
$this->request->remove($offset);
47+
$this->offsetUnset($offset);
5648

5749
return $this;
5850
});
5951

6052
Request::macro('forceReplace', function (array $data): Request {
6153
/** @var Request $this */
6254

63-
if ($this->isJson()) {
64-
$this->json()->replace($data);
65-
}
66-
67-
if ($this->query->count() > 0) {
68-
$this->query->replace($data);
69-
}
70-
71-
if ($this->request->count() > 0) {
72-
$this->request->replace($data);
73-
}
55+
$this->query->replace();
56+
$this->request->replace();
57+
$this->replace($data);
7458

7559
return $this;
7660
});

0 commit comments

Comments
 (0)