@foreach ($value as $m)
@php
$res = str_split(format()->result($m));
// Remove nulls and keep order
$res = array_values(array_filter($res, fn($v) => $v !== null));
// Ensure 4 elements, filling the missing ones with null at the end
$res = array_pad($res, 4, null);
// Calculate `d` based on the last two numeric values
$d = substr((string) (($res[2] ?? 0) + ($res[3] ?? 0)), -1);
@endphp