Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/Admin/UsersController.php
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | public function index() | ||||
$domain = Domain::withTrashed()->where('namespace', $search) | $domain = Domain::withTrashed()->where('namespace', $search) | ||||
->first(); | ->first(); | ||||
if ($domain) { | if ($domain) { | ||||
if (($wallet = $domain->wallet()) && ($owner = $wallet->owner()->withTrashed()->first())) { | if (($wallet = $domain->wallet()) && ($owner = $wallet->owner()->withTrashed()->first())) { | ||||
$result->push($owner); | $result->push($owner); | ||||
} | } | ||||
} | } | ||||
// A mollie customer ID | |||||
mollekopf: Add a comment that this is a search by mollie customerId | |||||
} elseif (substr($search, 0, 4) == 'cst_') { | |||||
Done Inline ActionsThis should include ->where('key', 'mollie_id'), but even then it will not use an index and might be slow. machniak: This should include `->where('key', 'mollie_id')`, but even then it will not use an index and… | |||||
Done Inline ActionsI believe if not found first() will return null and therefore you'd try to invoke wallet() on null? mollekopf: I believe if not found first() will return null and therefore you'd try to invoke wallet() on… | |||||
Done Inline ActionsNevermind, I figured out what the cst_ and tr_ prefixes are. mollekopf: Nevermind, I figured out what the cst_ and tr_ prefixes are. | |||||
Done Inline ActionsIs it intended that the value is matched against "cst_$something" or should the search only be executed against $something without the cst_ prefix? Same below. mollekopf: Is it intended that the value is matched against "cst_$something" or should the search only be… | |||||
$setting = \App\WalletSetting::where( | |||||
[ | |||||
'key' => 'mollie_id', | |||||
'value' => $search | |||||
] | |||||
)->first(); | |||||
Done Inline ActionsAdd a comment that this is a search by mollie payment id. mollekopf: Add a comment that this is a search by mollie payment id. | |||||
if ($setting) { | |||||
if ($setting->wallet()) { | |||||
if ($owner = $wallet->owner()->withTrashed()->first()) { | |||||
machniakUnsubmitted Not Done Inline Actions$wallet does not exist. machniak: $wallet does not exist. | |||||
Not Done Inline Actionsmust be owner() as you build the query here. machniak: must be owner() as you build the query here. | |||||
$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()) { | |||||
machniakUnsubmitted Not Done Inline ActionsShould be $payment->wallet->... machniak: Should be $payment->wallet->... | |||||
Not Done Inline Actionsowner() machniak: owner() | |||||
$result->push($owner); | |||||
} | |||||
} | |||||
} elseif (!empty($search)) { | } elseif (!empty($search)) { | ||||
$wallet = Wallet::find($search); | $wallet = Wallet::find($search); | ||||
if ($wallet) { | if ($wallet) { | ||||
if ($owner = $wallet->owner()->withTrashed()->first()) { | if ($owner = $wallet->owner()->withTrashed()->first()) { | ||||
$result->push($owner); | $result->push($owner); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 208 Lines • Show Last 20 Lines |
Add a comment that this is a search by mollie customerId