*/ public function columns(Tenant $tenant): array { $keys = $tenant->codigo === self::FIESTA_FUTBOL_INFANTIL ? ['order_number', 'category', 'product', 'type', 'date', 'size', 'amount', 'client', 'id', 'status', 'scanned_by'] : ['order_number', 'product', 'amount', 'client', 'id', 'status', 'scanned_by']; $columns = array_map(fn (string $key): array => $this->definitions()[$key], $keys); if ($tenant->codigo === self::FIESTA_FUTBOL_INFANTIL) { $columns = array_map(function (array $column): array { if (in_array($column['key'], ['product', 'type', 'date', 'size'], true)) { $column['sortable'] = false; } return $column; }, $columns); } else { $widths = [ 'order_number' => '11%', 'product' => '15%', 'amount' => '10%', 'client' => '15%', 'id' => '8%', 'status' => '8%', 'scanned_by' => '11%', ]; $columns = array_map(function (array $column) use ($widths): array { $column['width'] = $widths[$column['key']]; return $column; }, $columns); } return $columns; } /** @return list */ public function publicColumns(Tenant $tenant): array { return array_map(function (array $column): array { unset($column['excel_width']); return $column; }, $this->columns($tenant)); } /** @return list */ public function sortableKeys(Tenant $tenant): array { return array_values(array_map( fn (array $column): string => $column['sort_param'], array_filter($this->columns($tenant), fn (array $column): bool => $column['sortable']), )); } /** @return array */ private function definitions(): array { return [ 'order_number' => $this->column('order_number', 'N° de orden', 'order_number', '10.5%', 14), 'category' => $this->column('category', 'Categoría', 'text', '11%', 18), 'product' => $this->column('product', 'Producto', 'text', '11%', 22), 'type' => $this->column('type', 'Tipo', 'text', '8%', 18), 'date' => $this->column('date', 'Fecha', 'text', '7%', 14), 'size' => $this->column('size', 'Talle', 'text', '6%', 12), 'amount' => $this->column('amount', 'Importe', 'currency', '8%', 15), 'client' => $this->column('client', 'Cliente', 'text', '11%', 30), 'id' => $this->column('id', 'ID', 'text', '6%', 12), 'status' => $this->column('status', 'Estado', 'status', '7%', 13), 'scanned_by' => $this->column('scanned_by', 'Escaneado por', 'text', '8%', 28), ]; } /** @return array{key: string, label: string, type: string, sortable: bool, sort_param: string, width: string, excel_width: int} */ private function column( string $key, string $label, string $type, string $width, int $excelWidth, ): array { return [ 'key' => $key, 'label' => $label, 'type' => $type, 'sortable' => true, 'sort_param' => $key, 'width' => $width, 'excel_width' => $excelWidth, ]; } }