Add Ladill POS v1 — register, Pay checkout, and commerce links.
Deploy Ladill Mini / deploy (push) Successful in 23s
Deploy Ladill Mini / deploy (push) Successful in 23s
Staff-facing counter register at pos.ladill.com with catalog cart, cash and MoMo/card checkout via Ladill Pay, CRM timeline/import, invoice prefill, and Merchant catalog import. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\MiniPayment;
|
||||
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_PAYMENT)
|
||||
->pluck('id');
|
||||
|
||||
if ($qrIds->isEmpty()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return MiniPayment::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('payer_note', '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 (MiniPayment $payment): array {
|
||||
$amount = number_format(
|
||||
($payment->status === MiniPayment::STATUS_PAID ? $payment->merchant_amount_minor : $payment->amount_minor) / 100,
|
||||
2,
|
||||
);
|
||||
|
||||
return [
|
||||
'type' => 'payment',
|
||||
'title' => $payment->payer_name ?: 'Walk-in customer',
|
||||
'subtitle' => 'GHS '.$amount.' · '.($payment->qrCode?->label ?? 'Payment QR').' · '.ucfirst($payment->status),
|
||||
'url' => route('mini.payments.index', ['q' => $payment->reference]),
|
||||
];
|
||||
})
|
||||
->all();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user