DateTime Method issue #265

Closed
opened 2026-04-07 09:27:50 +00:00 by DL-Works · 3 comments
DL-Works commented 2026-04-07 09:27:50 +00:00 (Migrated from github.com)

When in the export a column such as 'created_at' is included having a method of dateTime(), it failes with the error that created_at is not mounted!

TextColumn::make('created_at') ->label('Created At') ->dateTime() ->sortable()

Image

@pxlrbt

When in the export a column such as 'created_at' is included having a method of dateTime(), it failes with the error that created_at is not mounted! `TextColumn::make('created_at') ->label('Created At') ->dateTime() ->sortable()` <img width="525" height="229" alt="Image" src="https://github.com/user-attachments/assets/edb21f6b-5a01-4e29-a8cb-a497496b009b" /> @pxlrbt
zajinx commented 2026-06-10 11:20:39 +00:00 (Migrated from github.com)

you could try to write a patch

--- a/src/Exports/Concerns/WithColumns.php
+++ b/src/Exports/Concerns/WithColumns.php
@@ -165,6 +165,16 @@ trait WithColumns
         $vars = $reflect->getClosureUsedVariables();
 
         foreach ($vars as $name => $value) {
+            // Filament v5 stores the default date/time display format as a closure
+            // that resolves it from the column's table. Evaluate it while the column
+            // is still mounted, because the column is detached from its table before
+            // the export runs (for queue serialization).
+            if ($name === 'format' && $value instanceof Closure) {
+                $vars[$name] = $invadedColumn->evaluate($value);
+
+                continue;
+            }
+
             if (! is_null($value)) {
                 continue;
             }

then add to composer.json:

    "extra": {
        "laravel": {
            "dont-discover": []
        },
        "enable-patching": true,
        "patches": {
            "pxlrbt/filament-excel": {
                "Evaluate Filament v5 lazy date format closures before the column is detached from its table (fixes 'The column [x] is not mounted to a table' on export)": "patches/pxlrbt-filament-excel-evaluate-lazy-format-closure.patch"
            }
        }
    },
you could try to write a patch ``` --- a/src/Exports/Concerns/WithColumns.php +++ b/src/Exports/Concerns/WithColumns.php @@ -165,6 +165,16 @@ trait WithColumns $vars = $reflect->getClosureUsedVariables(); foreach ($vars as $name => $value) { + // Filament v5 stores the default date/time display format as a closure + // that resolves it from the column's table. Evaluate it while the column + // is still mounted, because the column is detached from its table before + // the export runs (for queue serialization). + if ($name === 'format' && $value instanceof Closure) { + $vars[$name] = $invadedColumn->evaluate($value); + + continue; + } + if (! is_null($value)) { continue; } ``` then add to composer.json: ``` "extra": { "laravel": { "dont-discover": [] }, "enable-patching": true, "patches": { "pxlrbt/filament-excel": { "Evaluate Filament v5 lazy date format closures before the column is detached from its table (fixes 'The column [x] is not mounted to a table' on export)": "patches/pxlrbt-filament-excel-evaluate-lazy-format-closure.patch" } } }, ```
Jacobtims commented 2026-06-16 13:22:51 +00:00 (Migrated from github.com)

Filament version: v4.11.7
Filament-excel version: v3.6.1

Filament version: v4.11.7 Filament-excel version: v3.6.1
Jacobtims commented 2026-06-16 13:24:43 +00:00 (Migrated from github.com)

I think this might be related to #234

I think this might be related to #234
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pxlrbt/filament-excel#265
No description provided.