User table list omits the status column

I created a resource for managing the users table and one of the columns on the table is called 'status'. For some bizarre reason this column does not get listed in the table. If however I change the column name in the database to something other than 'status' then it will be displayed/listed normally.... Table code as generated by filament when the resource was created is:- Tables\Columns\TextColumn::make('status') ->searchable(), Any ideas?
Solution:
Done some more testing with this. It doesn't have to be the 'status' column. It seems that if any column is made toggleable and gets hidden using the selector then even if the toggleable() attribute is removed from the table's schema definition then it stays hidden and cannot be displayed until toggleable is restored and the column is reset to visible. Once that is done then the toggleable() can be removed... Where is the toggleable status remembered? Local storage?...
Jump to solution
32 Replies
Dennis Koch
Dennis Koch2y ago
Can you share the full table definition?
rich06
rich06OP2y ago
public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('firstname') ->searchable(), Tables\Columns\TextColumn::make('lastname') ->searchable(), Tables\Columns\TextColumn::make('email') ->searchable(), Tables\Columns\TextColumn::make('mobile') ->searchable(), Tables\Columns\TextColumn::make('email_verified_at') ->dateTime() ->sortable(), Tables\Columns\TextColumn::make('avatar_url') ->searchable(), Tables\Columns\TextColumn::make('status') ->searchable(), Tables\Columns\TextColumn::make('created_at') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), Tables\Columns\TextColumn::make('updated_at') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), ]) ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ]) ->emptyStateActions([ Tables\Actions\CreateAction::make(), ]); }
Dennis Koch
Dennis Koch2y ago
Weird one. What does a toArray() on your model return?
rich06
rich06OP2y ago
Here's an example from the db [ "id" => 3, "firstname" => "Client", "lastname" => "User", "email" => "[email protected]", "mobile" => "099933011", "email_verified_at" => null, "avatar_url" => null, "status" => "Active", "created_at" => "2023-08-18T20:04:05.000000Z", "updated_at" => "2023-08-18T20:04:05.000000Z", "full_name" => "Client User", "breezy_sessions" => [], ] If it helps here are the attributes for the same user from dumping a get() of the getEloquentquery() in the resource:- #attributes: array:12 [▼ "id" => 3 "firstname" => "Client" "lastname" => "User" "email" => "[email protected]" "mobile" => "099933011" "email_verified_at" => null "password" => "$2y$10$eJmL/1wpyrMgB4wX19tLxeuBsdxsAAKF1wle09cqjHrw6I4LTqrPy" "remember_token" => null "avatar_url" => null "status" => "Active" "created_at" => "2023-08-18 20:04:05" "updated_at" => "2023-08-18 20:04:05" ]
Dennis Koch
Dennis Koch2y ago
Can you dump a ->toArray()
rich06
rich06OP2y ago
Here you go 2 => array:12 [▼ "id" => 3 "firstname" => "Client" "lastname" => "User" "email" => "[email protected]" "mobile" => "099933011" "email_verified_at" => null "avatar_url" => null "status" => "Active" "created_at" => "2023-08-18T20:04:05.000000Z" "updated_at" => "2023-08-18T20:04:05.000000Z" "full_name" => "Client User" "breezy_sessions" => [] ]
Dennis Koch
Dennis Koch2y ago
Hm weird. Looks fine to me. Was the column toggleable() before? Does this show up? 1.
Tables\Columns\TextColumn::make('status')
->getStateUsing(fn ($record) => $record->status)
->searchable(),
Tables\Columns\TextColumn::make('status')
->getStateUsing(fn ($record) => $record->status)
->searchable(),
2.
Tables\Columns\TextColumn::make('status_test')
->getStateUsing(fn ($record) => $record->status)
->searchable(),
Tables\Columns\TextColumn::make('status_test')
->getStateUsing(fn ($record) => $record->status)
->searchable(),
toeknee
toeknee2y ago
Do you have a status relationship on the records model?
Dennis Koch
Dennis Koch2y ago
Yeah, maybe share your model code
rich06
rich06OP2y ago
Exception Method Filament\Tables\Columns\TextColumn::getRecordUsing does not exist
Dennis Koch
Dennis Koch2y ago
Sorry. getStateUsing
rich06
rich06OP2y ago
'status_test' is listed 'status' is still missing
Dennis Koch
Dennis Koch2y ago
What about this:
Was the column toggleable() before?
toeknee
toeknee2y ago
Can you try adding toggleable lol That's what I was thinking Dennis 😄
rich06
rich06OP2y ago
No - the resource is as generated by filament
Dennis Koch
Dennis Koch2y ago
Can you try in an incognito browser window?
rich06
rich06OP2y ago
I added ->toggleable() no change status is missing from list still
toeknee
toeknee2y ago
Can you see the status as toggleable in the toggleable list now?
rich06
rich06OP2y ago
Okay - that works ...
Dennis Koch
Dennis Koch2y ago
Sounds like something stored in browser cache then
rich06
rich06OP2y ago
Okay - thanks for your help (@toeknee too!) .. will clear cache/cookies and start over Correction - it only seems to work with toggleable() added - I removed it from incognoto session and it isn't listed again...
toeknee
toeknee2y ago
Yeah a toggleable filter for status was stored Do: ->toggleable(isToggledHiddenByDefault: false)
rich06
rich06OP2y ago
It is still not listed but appears in the toggleable field list then appears when selected
Dennis Koch
Dennis Koch2y ago
I think the default is alredy set by now.
toeknee
toeknee2y ago
Twas for his inprivate sessions 😉 Can you provie a github repo to replicate it
rich06
rich06OP2y ago
so if toggleable has been added then it is rememered and applied even if the toggleable attribute is removed?
toeknee
toeknee2y ago
Yes possibly since the togglebale is session based
Dennis Koch
Dennis Koch2y ago
Yeah, that sounds like an issue. Can you please open one on GH with a reproduction repo? Shouldn't be applied though, if you remove it
toeknee
toeknee2y ago
True
Solution
rich06
rich062y ago
Done some more testing with this. It doesn't have to be the 'status' column. It seems that if any column is made toggleable and gets hidden using the selector then even if the toggleable() attribute is removed from the table's schema definition then it stays hidden and cannot be displayed until toggleable is restored and the column is reset to visible. Once that is done then the toggleable() can be removed... Where is the toggleable status remembered? Local storage?
toeknee
toeknee2y ago
IT is in session storage and that would be expected tbh because it's not something you do often.
rich06
rich06OP2y ago
okay understood

Did you find this page helpful?