Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/Admin/WalletsController.php
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | public function oneOff(Request $request, $id) | ||||
'description' => 'required|string|max:1024', | 'description' => 'required|string|max:1024', | ||||
] | ] | ||||
); | ); | ||||
if ($v->fails()) { | if ($v->fails()) { | ||||
return response()->json(['status' => 'error', 'errors' => $v->errors()], 422); | return response()->json(['status' => 'error', 'errors' => $v->errors()], 422); | ||||
} | } | ||||
$amount = (int) ($request->amount * 100); | $amount = (int) round($request->amount * 100); | ||||
$method = $amount > 0 ? 'award' : 'penalty'; | $method = $amount > 0 ? 'award' : 'penalty'; | ||||
DB::beginTransaction(); | DB::beginTransaction(); | ||||
$wallet->{$method}(abs($amount), $request->description); | $wallet->{$method}(abs($amount), $request->description); | ||||
if ($user->role == 'reseller') { | if ($user->role == 'reseller') { | ||||
if ($user->tenant && ($tenant_wallet = $user->tenant->wallet())) { | if ($user->tenant && ($tenant_wallet = $user->tenant->wallet())) { | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |