Page MenuHomePhorge

D2740.1775368244.diff
No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None

D2740.1775368244.diff

diff --git a/src/app/Http/Controllers/API/V4/Admin/UsersController.php b/src/app/Http/Controllers/API/V4/Admin/UsersController.php
--- a/src/app/Http/Controllers/API/V4/Admin/UsersController.php
+++ b/src/app/Http/Controllers/API/V4/Admin/UsersController.php
@@ -90,6 +90,31 @@
$result->push($owner);
}
}
+ // A mollie customer ID
+ } elseif (substr($search, 0, 4) == 'cst_') {
+ $setting = \App\WalletSetting::where(
+ [
+ 'key' => 'mollie_id',
+ 'value' => $search
+ ]
+ )->first();
+
+ if ($setting) {
+ if ($wallet = $setting->wallet) {
+ if ($owner = $wallet->owner()->withTrashed()->first()) {
+ $result->push($owner);
+ }
+ }
+ }
+ // A mollie transaction ID
+ } elseif (substr($search, 0, 3) == 'tr_') {
+ $payment = \App\Payment::find($search);
+
+ if ($payment) {
+ if ($owner = $payment->wallet->owner()->withTrashed()->first()) {
+ $result->push($owner);
+ }
+ }
} elseif (!empty($search)) {
$wallet = Wallet::find($search);
diff --git a/src/tests/Feature/Controller/Admin/UsersTest.php b/src/tests/Feature/Controller/Admin/UsersTest.php
--- a/src/tests/Feature/Controller/Admin/UsersTest.php
+++ b/src/tests/Feature/Controller/Admin/UsersTest.php
@@ -189,6 +189,24 @@
$plan = \App\Plan::where('title', 'group')->first();
$user->assignPlan($plan, $domain);
$user->setAliases(['alias@testsearch.com']);
+
+ $wallet = $user->wallets()->first();
+ $wallet->setSetting('mollie_id', 'cst_nonsense');
+
+ \App\Payment::create(
+ [
+ 'id' => 'tr_nonsense',
+ 'wallet_id' => $wallet->id,
+ 'status' => 'paid',
+ 'amount' => 1337,
+ 'description' => 'nonsense transaction for testing',
+ 'provider' => 'self',
+ 'type' => 'oneoff',
+ 'currency' => 'CHF',
+ 'currency_amount' => 1337
+ ]
+ );
+
Queue::fake();
$user->delete();
@@ -224,6 +242,39 @@
$this->assertSame($user->id, $json['list'][0]['id']);
$this->assertSame($user->email, $json['list'][0]['email']);
$this->assertTrue($json['list'][0]['isDeleted']);
+
+ $response = $this->actingAs($admin)->get("api/v4/users?search={$wallet->id}");
+ $response->assertStatus(200);
+
+ $json = $response->json();
+
+ $this->assertSame(1, $json['count']);
+ $this->assertCount(1, $json['list']);
+ $this->assertSame($user->id, $json['list'][0]['id']);
+ $this->assertSame($user->email, $json['list'][0]['email']);
+ $this->assertTrue($json['list'][0]['isDeleted']);
+
+ $response = $this->actingAs($admin)->get("api/v4/users?search=tr_nonsense");
+ $response->assertStatus(200);
+
+ $json = $response->json();
+
+ $this->assertSame(1, $json['count']);
+ $this->assertCount(1, $json['list']);
+ $this->assertSame($user->id, $json['list'][0]['id']);
+ $this->assertSame($user->email, $json['list'][0]['email']);
+ $this->assertTrue($json['list'][0]['isDeleted']);
+
+ $response = $this->actingAs($admin)->get("api/v4/users?search=cst_nonsense");
+ $response->assertStatus(200);
+
+ $json = $response->json();
+
+ $this->assertSame(1, $json['count']);
+ $this->assertCount(1, $json['list']);
+ $this->assertSame($user->id, $json['list'][0]['id']);
+ $this->assertSame($user->email, $json['list'][0]['email']);
+ $this->assertTrue($json['list'][0]['isDeleted']);
}
/**

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 5, 5:50 AM (5 h, 41 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18822856
Default Alt Text
D2740.1775368244.diff (3 KB)

Event Timeline