Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117910663
D2740.1775397262.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D2740.1775397262.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 1:54 PM (2 h, 13 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18822856
Default Alt Text
D2740.1775397262.diff (3 KB)
Attached To
Mode
D2740: Allow search with transaction and customer IDs
Attached
Detach File
Event Timeline