|
|
@@ -43,8 +43,17 @@ class WalletController extends AgentApiController
|
|
|
'bank_name' => ['nullable', 'string', 'max:128'], 'network' => ['nullable', 'string', 'max:32'],
|
|
|
'details' => ['nullable', 'array'], 'status' => ['nullable', 'integer', 'in:0,1'],
|
|
|
]);
|
|
|
+ $isNew = empty($data['id']);
|
|
|
+ foreach (['name', 'bank_name', 'network'] as $field) {
|
|
|
+ if ($isNew || array_key_exists($field, $data)) {
|
|
|
+ $data[$field] = trim((string) ($data[$field] ?? ''));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($isNew || array_key_exists('status', $data)) {
|
|
|
+ $data['status'] = $data['status'] ?? 1;
|
|
|
+ }
|
|
|
$agent = $this->currentAgent();
|
|
|
- $account = empty($data['id']) ? new AgentWithdrawAccount() : AgentWithdrawAccount::query()->where('agent_id', $agent->id)->findOrFail($data['id']);
|
|
|
+ $account = $isNew ? new AgentWithdrawAccount() : AgentWithdrawAccount::query()->where('agent_id', $agent->id)->findOrFail($data['id']);
|
|
|
$account->fill($data);
|
|
|
$account->agent_id = $agent->id;
|
|
|
$account->save();
|