Add mobile API for Ladill Mini Android app.
Deploy Ladill Mini / deploy (push) Successful in 47s

Token login via OAuth password grant against auth.ladill.com (AuthController),
plus /api/v1/mini endpoints (overview, payment-qrs CRUD + preview, payments,
payouts) mirroring the web Mini controllers. Sanctum abilities mini:read/write.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
isaacclad
2026-06-10 22:13:30 +00:00
co-authored by Claude Opus 4.8
parent 70ded0e668
commit 307248749b
7 changed files with 501 additions and 7 deletions
@@ -0,0 +1,59 @@
<?php
namespace App\Http\Controllers\Api\Mini;
use App\Http\Controllers\Controller;
use App\Models\MiniPayment;
use App\Models\QrCode;
use App\Services\Billing\BillingClient;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use Throwable;
class OverviewController extends Controller
{
public function __construct(private BillingClient $billing) {}
public function __invoke(): JsonResponse
{
$account = ladill_account();
$qrIds = $account->qrCodes()
->where('type', QrCode::TYPE_PAYMENT)
->pluck('id');
$todayPayments = MiniPayment::query()
->whereIn('qr_code_id', $qrIds)
->where('status', MiniPayment::STATUS_PAID)
->where('paid_at', '>=', now()->startOfDay());
$recentPayments = MiniPayment::query()
->whereIn('qr_code_id', $qrIds)
->where('status', MiniPayment::STATUS_PAID)
->with('qrCode')
->latest('paid_at')
->limit(8)
->get();
$balanceMinor = 0;
try {
$balanceMinor = $this->billing->balanceMinor($account->public_id);
} catch (Throwable $e) {
Log::warning('Mini API overview could not load wallet balance', [
'user' => $account->public_id,
'error' => $e->getMessage(),
]);
}
return response()->json([
'data' => [
'currency' => 'GHS',
'today_takings_minor' => (int) (clone $todayPayments)->sum('merchant_amount_minor'),
'today_count' => (clone $todayPayments)->count(),
'payment_qr_count' => $qrIds->count(),
'wallet_balance_minor' => $balanceMinor,
'recent_payments' => $recentPayments->map(fn (MiniPayment $p) => PaymentPresenter::present($p))->values(),
],
]);
}
}