Initial Ladill Give extraction — online giving pages at give.ladill.com.

Donation checkout via Ladill Pay (9% fee), church/giving QR pages, SSO, and platform scan forwarding.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-06-09 07:25:49 +00:00
co-authored by Cursor
commit 0860b08af7
295 changed files with 37190 additions and 0 deletions
+71
View File
@@ -0,0 +1,71 @@
<?php
namespace App\Http\Controllers;
use App\Models\GiveDonation;
use App\Models\QrCode;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class SearchController extends Controller
{
public function __invoke(Request $request): JsonResponse|View
{
$q = trim((string) $request->query('q'));
$results = mb_strlen($q) >= 2 ? $this->results($q) : [];
if ($request->expectsJson() || $request->ajax() || $request->wantsJson()) {
return response()->json(['results' => $results]);
}
return view('search.index', [
'query' => $q,
'results' => $results,
]);
}
/** @return list<array{type: string, title: string, subtitle: string, url: string}> */
private function results(string $q): array
{
$account = ladill_account();
$like = '%'.$q.'%';
$qrIds = $account->qrCodes()
->where('type', QrCode::TYPE_CHURCH)
->pluck('id');
if ($qrIds->isEmpty()) {
return [];
}
return GiveDonation::query()
->whereIn('qr_code_id', $qrIds)
->with('qrCode')
->where(function ($query) use ($like) {
$query->where('payer_name', 'like', $like)
->orWhere('payer_email', 'like', $like)
->orWhere('collection_type', 'like', $like)
->orWhere('reference', 'like', $like)
->orWhere('payment_reference', 'like', $like)
->orWhereHas('qrCode', fn ($qr) => $qr->where('label', 'like', $like));
})
->latest('created_at')
->limit(15)
->get()
->map(function (GiveDonation $donation): array {
$amount = number_format(
($donation->status === GiveDonation::STATUS_PAID ? $donation->merchant_amount_minor : $donation->amount_minor) / 100,
2,
);
return [
'type' => 'donation',
'title' => $donation->payer_name ?: 'Anonymous donor',
'subtitle' => 'GHS '.$amount.' · '.($donation->collection_type ?: 'Donation').' · '.ucfirst($donation->status),
'url' => route('give.donations.index', ['q' => $donation->reference]),
];
})
->all();
}
}