feat(forms): expose grouped admin sale statuses
This commit is contained in:
@@ -6,27 +6,18 @@ use App\Domains\Purchase\Models\Purchase;
|
||||
|
||||
class SaleFormService
|
||||
{
|
||||
/** @return array{statuses: list<array{code: string, name: string}>} */
|
||||
/** @return array{statuses: list<array{value: string, label: string, real_statuses: list<string>}>} */
|
||||
public function get(): array
|
||||
{
|
||||
$names = [
|
||||
Purchase::STATUS_CREATED => 'Creada',
|
||||
Purchase::STATUS_PENDING_PAYMENT => 'Esperando pago',
|
||||
Purchase::STATUS_IN_REVIEW => 'En revisión',
|
||||
Purchase::STATUS_PAID => 'Confirmada',
|
||||
Purchase::STATUS_CANCELLED => 'Cancelada',
|
||||
Purchase::STATUS_REJECTED => 'Rechazada',
|
||||
Purchase::STATUS_EXPIRED => 'Vencida',
|
||||
Purchase::STATUS_SUPERSEDED => 'Reemplazada',
|
||||
];
|
||||
|
||||
return [
|
||||
'statuses' => array_map(
|
||||
fn (string $status): array => [
|
||||
'code' => $status,
|
||||
'name' => $names[$status],
|
||||
fn (string $code, array $definition): array => [
|
||||
'value' => $code,
|
||||
'label' => $definition['name'],
|
||||
'real_statuses' => $definition['statuses'],
|
||||
],
|
||||
Purchase::statuses(),
|
||||
array_keys(Purchase::adminStatuses()),
|
||||
array_values(Purchase::adminStatuses()),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user