Skip to content

Commit 8041138

Browse files
Thibault GRANADATZK-
authored andcommitted
[Model] Forward global scope to delete queries
1 parent 22e20e1 commit 8041138

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/Api.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ protected function create(string $endpoint, $attributes)
151151
*
152152
* @return mixed|array
153153
*/
154-
protected function delete(string $endpoint, $id)
154+
protected function delete(string $endpoint, $id, array $data = [])
155155
{
156156
$key = $endpoint.'/'.$id.'?';
157157
$this->deleteCache($key);
158158

159-
return $this->getTransport()->request('/'.$endpoint.'/'.$id, [], 'delete') ?? [];
159+
return $this->getTransport()->request('/'.$endpoint.'/'.$id, $data, 'delete') ?? [];
160160
}
161161
}

src/Model.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,10 @@ protected function performInsert()
595595
*/
596596
protected function performDeleteOnModel()
597597
{
598-
$this->getApi()->{'delete'.ucfirst($this->getEntity())}($this->{$this->primaryKey});
598+
$this->getApi()->{'delete'.ucfirst($this->getEntity())}(
599+
$this->{$this->primaryKey},
600+
array_merge(...array_values($this->getGlobalScopes()))
601+
);
599602

600603
$this->exists = false;
601604
}

src/Transports/Transport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function rawRequest($endpoint, array $data = [], $method = 'get')
145145
break;
146146
case 'delete':
147147
$url = $this->getUrl($endpoint);
148-
$this->getClient()->delete($url, $this->encodeBody($data));
148+
$this->getClient()->delete($url, $data);
149149
break;
150150
}
151151

0 commit comments

Comments
 (0)