@php
/**
* The saved-method rows, on their own so the server can re-render JUST this list.
*
* Choosing a different default is a one-field change; reloading the entire account page to show a
* tick move was the heaviest possible way to say it. Account\PaymentMethodController renders this
* fragment and hands it back, and the page swaps the list in place — see account-payment.js.
*
* @var array $methods this user's methods, best first
*/
$methods = $methods ?? [];
$cardModel = new \App\Models\PaymentMethod();
@endphp
@foreach ($methods as $m)
@php
$usable = \App\Models\PaymentMethod::isUsable($m);
$ident = payment_method_ident($m);
$expires = (int) $m['exp_year'] > 0
? t_raw('account.exp_prefix') . ' ' . str_pad((string) (int) $m['exp_month'], 2, '0', STR_PAD_LEFT) . '/' . substr((string) (int) $m['exp_year'], -2)
: '';
$detail = trim(implode(' · ', array_filter([$ident, $expires])));
@endphp
-
@php /* THE ROW IS THE CONTROL. Choosing which method to use is a choice between
the rows, so the row itself is what you press and the tick moves to it —
a "Make default" label on every line said out loud what the tick already
shows, five times over. The default row is not a button: pressing the
thing that is already chosen should do nothing. */
@endphp
@if (empty($m['is_default']))
@else
{!! card_brand_mark((string) $m['brand'], 24) !!}
{{ card_brand_label((string) $m['brand']) }}
@if ($detail !== '' || !$usable)
{{ $detail }}@if (!$usable) {{ t_raw('account.card_expired_pill') }}@endif
@endif
@endif
@if (!empty($m['is_default']))
{{ t_raw('vendor.reservations.default_pill') }}
@endif
@if ($cardModel->canDelete((int) ($m['user_id'] ?? 0), $m))
@endif
@endforeach