alperenersoy / filament-export

Customizable export and print functionality for Filament Admin Panel
211 stars 49 forks source link

Method App\Filament\Resources\UserResource\Pages\ListUsers::getCachedTableColumns does not exist. #100

Open faizananwerali opened 1 year ago

faizananwerali commented 1 year ago
Method App\Filament\Resources\UserResource\Pages\ListUsers::getCachedTableColumns does not exist.

I tried to run this but got an error,

app/Filament/Resources/UserResource/Pages/ListUsers.php

class ListUsers extends ListRecords
{
    protected static string $resource = UserResource::class;

    public ?string $tableSortColumn = 'created_at';

    public ?string $tableSortDirection = 'desc';

    // ....
}

If I comment out public ?string $tableSortColumn = 'created_at'; this, then the application is working.

This is an error in vendor/alperenersoy/filament-export/src/Actions/Concerns/HasRecords.php

    protected function applySortingToTableQuery(Builder $query): Builder
    {
        /** @var \Filament\Resources\Pages\ListRecords $livewire */
        $livewire = $this->getLivewire();

        $columnName = $livewire->tableSortColumn;

        if (!$columnName) {
            return $query;
        }

        $direction = $livewire->tableSortDirection === 'desc' ? 'desc' : 'asc';

        if ($column = $livewire->getCachedTableColumns()[$columnName]) {
            $column->applySort($query, $direction);

            return $query;
        }

        if ($columnName === $livewire->getDefaultSortColumn()) {
            return $query->orderBy($columnName, $direction);
        }

        return $query;
    }

Laravel v10 Filament v3 Livewire v3

lodekib commented 1 year ago
Method App\Filament\Resources\UserResource\Pages\ListUsers::getCachedTableColumns does not exist.

I tried to run this but got an error,

app/Filament/Resources/UserResource/Pages/ListUsers.php

class ListUsers extends ListRecords
{
    protected static string $resource = UserResource::class;

    public ?string $tableSortColumn = 'created_at';

    public ?string $tableSortDirection = 'desc';

    // ....
}

If I comment out public ?string $tableSortColumn = 'created_at'; this, then the application is working.

This is an error in vendor/alperenersoy/filament-export/src/Actions/Concerns/HasRecords.php

    protected function applySortingToTableQuery(Builder $query): Builder
    {
        /** @var \Filament\Resources\Pages\ListRecords $livewire */
        $livewire = $this->getLivewire();

        $columnName = $livewire->tableSortColumn;

        if (!$columnName) {
            return $query;
        }

        $direction = $livewire->tableSortDirection === 'desc' ? 'desc' : 'asc';

        if ($column = $livewire->getCachedTableColumns()[$columnName]) {
            $column->applySort($query, $direction);

            return $query;
        }

        if ($columnName === $livewire->getDefaultSortColumn()) {
            return $query->orderBy($columnName, $direction);
        }

        return $query;
    }

Laravel v10 Filament v3 Livewire v3

How did you install this packages' version for filament 3?

faizananwerali commented 1 year ago

@lodekib add this in composer.json file.

"alperenersoy/filament-export": "^3.0@beta",

and then run composer update for filament v3.

TranLTR commented 11 months ago

Hi, @faizananwerali , For me, doesn't work when export Table : League\Flysystem\Filesystem::has(): Argument #1 ($location) must be of type string, null given,

OccTherapist commented 6 months ago

I have the same issue on

Laravel 10 Filament 3 Livewire 3

Is this still an unsolved?