filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
18.39k stars 2.87k forks source link

Table query modification causes problem with record's row rendering at table view #9684

Closed jakubkopkiewicz closed 11 months ago

jakubkopkiewicz commented 11 months ago

Package

filament/filament

Package Version

v3.0.0

Laravel Version

v10

Livewire Version

v 3.0.0

PHP Version

PHP 8.1

Problem description

I'm trying to modify a table query of my resource by modifying table's query method. But after that there is no rendered rows at table view, but I see pagination, and I don't have an empty table message.

There is my code :

`<?php

namespace App\Filament\Resources\EngagementResource\Pages;

use App\Enums\Engagement\EngagementStatusEnum; use App\Filament\Resources\EngagementResource; use Filament\Actions; use Filament\Resources\Pages\ListRecords; use Filament\Tables\Table; use Illuminate\Database\Eloquent\Builder;

class ListEngagements extends ListRecords { protected static string $resource = EngagementResource::class;

protected function getHeaderActions(): array
{
    return [
        Actions\CreateAction::make(),
    ];
}

public function table(Table $table): Table
{
    return $table
        ->modifyQueryUsing(fn (Builder $query) => $query->where('status','offer));
}

} ` I made some test with query, and eloquent returns needed data correctly, also inside modified closure. Also when I just passed a query without any modification, still getting the same behavior.

Expected behavior

Records should be rendered properly

Steps to reproduce

Just try to modify table query.

Reproduction repository

Will be updated soon...

Relevant log output

No response

github-actions[bot] commented 11 months ago

Hey @jakubkopkiewicz! We're sorry to hear that you've hit this issue. 💛

However, it looks like you forgot to fill in the reproduction repository URL. Can you edit your original post and then we'll look at your issue?

We need a public GitHub repository which contains a Laravel app with the minimal amount of Filament code to reproduce the problem. Please do not link to your actual project, what we need instead is a minimal reproduction in a fresh project without any unnecessary code. This means it doesn't matter if your real project is private / confidential, since we want a link to a separate, isolated reproduction. That would allow us to download it and review your bug much easier, so it can be fixed quicker. Please make sure to include a database seeder with everything we need to set the app up quickly.

willcastillo commented 5 months ago

Solved here: https://github.com/filamentphp/filament/issues/8647