Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/WalletsController.php
Show First 20 Lines • Show All 240 Lines • ▼ Show 20 Lines | public function transactions($id) | ||||
if (count($result) > $pageSize) { | if (count($result) > $pageSize) { | ||||
$result->pop(); | $result->pop(); | ||||
$hasMore = true; | $hasMore = true; | ||||
} | } | ||||
} | } | ||||
$result = $result->map(function ($item) use ($isAdmin) { | $result = $result->map(function ($item) use ($isAdmin) { | ||||
$amount = $item->amount; | |||||
$negatives = [ | |||||
Transaction::WALLET_CHARGEBACK, | |||||
Transaction::WALLET_DEBIT, | |||||
Transaction::WALLET_PENALTY, | |||||
Transaction::WALLET_REFUND, | |||||
]; | |||||
if (in_array($item->type, $negatives)) { | |||||
$amount *= -1; | |||||
} | |||||
$entry = [ | $entry = [ | ||||
'id' => $item->id, | 'id' => $item->id, | ||||
'createdAt' => $item->created_at->format('Y-m-d H:i'), | 'createdAt' => $item->created_at->format('Y-m-d H:i'), | ||||
'type' => $item->type, | 'type' => $item->type, | ||||
'description' => $item->shortDescription(), | 'description' => $item->shortDescription(), | ||||
'amount' => $amount, | 'amount' => $item->amount, | ||||
'hasDetails' => !empty($item->cnt), | 'hasDetails' => !empty($item->cnt), | ||||
]; | ]; | ||||
if ($isAdmin && $item->user_email) { | if ($isAdmin && $item->user_email) { | ||||
$entry['user'] = $item->user_email; | $entry['user'] = $item->user_email; | ||||
} | } | ||||
return $entry; | return $entry; | ||||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |