F
Filament12mo ago
Levi B.

getTabs v3.2.77 error: trim(): Argument #1 ($string) must be of type string, Filament\Support\Enums\

Something has changed between Filament v3.2.76 and v3.2.77 with getTabs. In .76, this code works fine:
<?php

namespace App\Filament\Resources\EndpointResource\Pages;

use App\Filament\Resources\EndpointResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use Filament\Resources\Components\Tab;
use Filament\Support\Enums\IconPosition;
use Illuminate\Database\Eloquent\Builder;
use Archilex\AdvancedTables\AdvancedTables;

class ListEndpoints extends ListRecords
{
protected static string $resource = EndpointResource::class;

use AdvancedTables;

public function getTabs(): array
{
return [
'all' => Tab::make('All')
->label('All')
->icon('heroicon-m-ellipsis-horizontal-circle')
->iconPosition(IconPosition::After),
'live' => Tab::make('Live')
->label('Live')
->icon('heroicon-o-signal')
->iconPosition(IconPosition::After)
->modifyQueryUsing(fn (Builder $query) => $query->where('status', 'Live')),
'pending' => Tab::make('Pending')
->label('Pending')
->icon('heroicon-o-bolt-slash')
->iconPosition(IconPosition::After)
->modifyQueryUsing(fn (Builder $query) => $query->where('status', 'Pending')),
'inactive' => Tab::make('Inactive')
->label('Inactive')
->icon('heroicon-m-signal-slash')
->iconPosition(IconPosition::After)
->modifyQueryUsing(fn (Builder $query) => $query->where('status', 'Inactive')),
];
}

}
<?php

namespace App\Filament\Resources\EndpointResource\Pages;

use App\Filament\Resources\EndpointResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use Filament\Resources\Components\Tab;
use Filament\Support\Enums\IconPosition;
use Illuminate\Database\Eloquent\Builder;
use Archilex\AdvancedTables\AdvancedTables;

class ListEndpoints extends ListRecords
{
protected static string $resource = EndpointResource::class;

use AdvancedTables;

public function getTabs(): array
{
return [
'all' => Tab::make('All')
->label('All')
->icon('heroicon-m-ellipsis-horizontal-circle')
->iconPosition(IconPosition::After),
'live' => Tab::make('Live')
->label('Live')
->icon('heroicon-o-signal')
->iconPosition(IconPosition::After)
->modifyQueryUsing(fn (Builder $query) => $query->where('status', 'Live')),
'pending' => Tab::make('Pending')
->label('Pending')
->icon('heroicon-o-bolt-slash')
->iconPosition(IconPosition::After)
->modifyQueryUsing(fn (Builder $query) => $query->where('status', 'Pending')),
'inactive' => Tab::make('Inactive')
->label('Inactive')
->icon('heroicon-m-signal-slash')
->iconPosition(IconPosition::After)
->modifyQueryUsing(fn (Builder $query) => $query->where('status', 'Inactive')),
];
}

}
That same code results in this error in 3.2.77:
TypeError
PHP 8.3.6
10.48.10
trim(): Argument #1 ($string) must be of type string, Filament\Support\Enums\IconPosition given
TypeError
PHP 8.3.6
10.48.10
trim(): Argument #1 ($string) must be of type string, Filament\Support\Enums\IconPosition given
I'm not sure what I'm doing wrong, as that appears to be valid usage according to documentation.
Solution:
Issue resolved by removing published filament-views: /resources/views/vendor/filament
Jump to solution
12 Replies
Levi B.
Levi B.OP12mo ago
I didn't mention, I tried this as well with iconPosition -- or giving no iconPosition at all. The problem persists: ->iconPosition(IconPosition::Before),
LeandroFerreira
LeandroFerreira12mo ago
->iconPosition('after') works?
Levi B.
Levi B.OP12mo ago
on 3.2.76, yes. When I update to anything after that -- including up to .80 (latest at time of this comment) it fails with this error:
No description
Levi B.
Levi B.OP12mo ago
No description
Levi B.
Levi B.OP12mo ago
Either one of these causes the trim() error above
No description
No description
Levi B.
Levi B.OP12mo ago
It looks like I'm going to have to put an "Issue" on github with a repo that showcases the error
LeandroFerreira
LeandroFerreira12mo ago
yes please
Andrew Wallo
Andrew Wallo12mo ago
What theme is this?
Levi B.
Levi B.OP11mo ago
GitHub
GitHub - BeardedBear/bearded-theme: The VS Code theme with a long b...
The VS Code theme with a long beard. Contribute to BeardedBear/bearded-theme development by creating an account on GitHub.
Levi B.
Levi B.OP11mo ago
I'm actually an idiot. The entire problem was that I published filament views and didn't listen to Dan here: https://filamentphp.com/community/danharrin-publishing-views-in-laravel -- I republished views, but ultimately I'd just like to "undo" the published views. Is it as simple as deleting the resources/views/vendor/filament directory?
Filament
Publishing Views in Laravel by Dan Harrin - 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.
Solution
Levi B.
Levi B.11mo ago
Issue resolved by removing published filament-views: /resources/views/vendor/filament
Uma
Uma5mo ago
\InvadersXX\FilamentJsoneditor\Forms\JSONEditor

Did you find this page helpful?