Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/UsersController.php
Show First 20 Lines • Show All 420 Lines • ▼ Show 20 Lines | public static function userResponse(User $user): array | ||||
$response['aliases'][] = $item->alias; | $response['aliases'][] = $item->alias; | ||||
} | } | ||||
// Status info | // Status info | ||||
$response['statusInfo'] = self::statusInfo($user); | $response['statusInfo'] = self::statusInfo($user); | ||||
$response = array_merge($response, self::userStatuses($user)); | $response = array_merge($response, self::userStatuses($user)); | ||||
// Add discount info to wallet object output | // Add more info to the wallet object output | ||||
$map_func = function ($wallet) use ($user) { | $map_func = function ($wallet) use ($user) { | ||||
$result = $wallet->toArray(); | $result = $wallet->toArray(); | ||||
if ($wallet->discount) { | if ($wallet->discount) { | ||||
$result['discount'] = $wallet->discount->discount; | $result['discount'] = $wallet->discount->discount; | ||||
$result['discount_description'] = $wallet->discount->description; | $result['discount_description'] = $wallet->discount->description; | ||||
} | } | ||||
if ($wallet->user_id != $user->id) { | if ($wallet->user_id != $user->id) { | ||||
$result['user_email'] = $wallet->owner->email; | $result['user_email'] = $wallet->owner->email; | ||||
} | } | ||||
$provider = \App\Providers\PaymentProvider::factory($wallet); | |||||
$result['provider'] = $provider->name(); | |||||
return $result; | return $result; | ||||
}; | }; | ||||
// Information about wallets and accounts for access checks | // Information about wallets and accounts for access checks | ||||
$response['wallets'] = $user->wallets->map($map_func)->toArray(); | $response['wallets'] = $user->wallets->map($map_func)->toArray(); | ||||
$response['accounts'] = $user->accounts->map($map_func)->toArray(); | $response['accounts'] = $user->accounts->map($map_func)->toArray(); | ||||
$response['wallet'] = $map_func($user->wallet()); | $response['wallet'] = $map_func($user->wallet()); | ||||
▲ Show 20 Lines • Show All 150 Lines • Show Last 20 Lines |