Skip to content

Commit 38db418

Browse files
committed
[Refactoring] Compare directly with the output of the delete() instead of querying the database again.
1 parent bd8ec7e commit 38db418

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/Repositories/ExpoDatabaseDriver.php

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,12 @@ public function retrieve(string $key)
4747
*/
4848
public function forget(string $key, string $value = null): bool
4949
{
50-
// Delete interest
51-
$delete = Interest::where('key', $key);
50+
$query = Interest::where('key', $key);
5251

53-
if (isset($value)) {
54-
// Only delete this token
55-
$delete->where('value', $value);
52+
if ($value) {
53+
$query->where('value', $value);
5654
}
5755

58-
$delete->delete();
59-
60-
// Check if our interest exist
61-
$count = Interest::where('key', $key);
62-
63-
if (isset($value)) {
64-
$count->where('value', $value);
65-
}
66-
67-
return $count->count() === 0;
56+
return $query->delete() > 0;
6857
}
6958
}

0 commit comments

Comments
 (0)