Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/WalletsController.php
Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | public function receipts($id) | ||||
// Only owner (or admin) has access to the wallet | // Only owner (or admin) has access to the wallet | ||||
if (!Auth::guard()->user()->canRead($wallet)) { | if (!Auth::guard()->user()->canRead($wallet)) { | ||||
return $this->errorResponse(403); | return $this->errorResponse(403); | ||||
} | } | ||||
$result = $wallet->payments() | $result = $wallet->payments() | ||||
->selectRaw('distinct date_format(updated_at, "%Y-%m") as ident') | ->selectRaw('distinct date_format(updated_at, "%Y-%m") as ident') | ||||
->where('status', PaymentProvider::STATUS_PAID) | ->where('status', PaymentProvider::STATUS_PAID) | ||||
->where('amount', '>', 0) | ->where('amount', '<>', 0) | ||||
->orderBy('ident', 'desc') | ->orderBy('ident', 'desc') | ||||
->get() | ->get() | ||||
->whereNotIn('ident', [date('Y-m')]) // exclude current month | ->whereNotIn('ident', [date('Y-m')]) // exclude current month | ||||
->pluck('ident'); | ->pluck('ident'); | ||||
return response()->json([ | return response()->json([ | ||||
'status' => 'success', | 'status' => 'success', | ||||
'list' => $result, | 'list' => $result, | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |