jak888
jak888
FFilament
Created by jak888 on 5/29/2024 in #❓┊help
display null values as 'null'
I have a table widget, where I want to display unconfirmed users. How can I display the string 'null' in the 'email_verified_at' column, when it's null? Here's what I have so far:
namespace App\Filament\Widgets;

use App\Filament\Resources\UserResource;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\Filter;
use Illuminate\Database\Eloquent\Builder;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;

class LatestUsers extends BaseWidget
{
protected int|string|array $columnSpan = 'full';
protected static ?int $sort = 1;

public function table(Table $table): Table
{
return $table
->query(
UserResource::getEloquentQuery()
)
->defaultPaginationPageOption(5)
->defaultSort('created_at', 'desc')
->columns([
TextColumn::make('created_at'),
TextColumn::make('name')
->searchable()
->sortable(),
TextColumn::make('email')
->searchable()
->sortable(),
TextColumn::make('email_verified_at')
->label('Confirmed?')
->formatStateUsing(fn(string $value): string => $value ? $value : 'null'), // <--- How do display null as a 'null'
])
->filters([
Filter::make('email_verified_at')
->label('Unconfirmed Users')
->default(true)
->query(fn(Builder $query): Builder => $query->whereNull('email_verified_at'))
])
->actions([
EditAction::make(),
]);
}
}
namespace App\Filament\Widgets;

use App\Filament\Resources\UserResource;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\Filter;
use Illuminate\Database\Eloquent\Builder;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;

class LatestUsers extends BaseWidget
{
protected int|string|array $columnSpan = 'full';
protected static ?int $sort = 1;

public function table(Table $table): Table
{
return $table
->query(
UserResource::getEloquentQuery()
)
->defaultPaginationPageOption(5)
->defaultSort('created_at', 'desc')
->columns([
TextColumn::make('created_at'),
TextColumn::make('name')
->searchable()
->sortable(),
TextColumn::make('email')
->searchable()
->sortable(),
TextColumn::make('email_verified_at')
->label('Confirmed?')
->formatStateUsing(fn(string $value): string => $value ? $value : 'null'), // <--- How do display null as a 'null'
])
->filters([
Filter::make('email_verified_at')
->label('Unconfirmed Users')
->default(true)
->query(fn(Builder $query): Builder => $query->whereNull('email_verified_at'))
])
->actions([
EditAction::make(),
]);
}
}
11 replies
FFilament
Created by jak888 on 5/22/2024 in #❓┊help
intl extension is required
Hi, I recetnly updated my application from laravel 10 to 11. After updating my composer files I started getting this error message on the filament admin panel: The "intl" PHP extension is required to use the [format] method. Why is this happening after the update? And how do I solve this? I ran composer require ext-intl, but I'm still getting the error. I run my local development environment on docker from wsl. Do I have to include intl in my docker image?
76 replies
FFilament
Created by jak888 on 5/7/2024 in #❓┊help
Displaying relation count in a column
Hi, I have an event table, a users table and a role table, they're linked through a pivot table named event_user_roles. This represents, what role a user is assigned for a given event. I have relations set up properly in the models. I would now like to display the number of users with a certain role in a upcomingEvents widget. How do I do that? The corresponding eloquent query would be:
$event->users()->join('roles', 'event_user_roles.role_id', '=', 'roles.id')
->select('events.id', \Illuminate\Support\Facades\DB::raw('SUM(if((roles.role = "kitchen"), 1, 0)) AS kitchen_count'))
->get();
$event->users()->join('roles', 'event_user_roles.role_id', '=', 'roles.id')
->select('events.id', \Illuminate\Support\Facades\DB::raw('SUM(if((roles.role = "kitchen"), 1, 0)) AS kitchen_count'))
->get();
How does that translate into my widget column?
29 replies
FFilament
Created by jak888 on 4/20/2024 in #❓┊help
getting 404 on livewire.min.js
Hi all, I'm getting the following error on my production site, when I try to access the /admin route: Failed to load resource: the server responded with a status of 404 () for the file livewire.min.js. This has previously been working and only happens on the production site. Why might this be happening?
48 replies
FFilament
Created by jak888 on 4/15/2024 in #❓┊help
getting error when trying to access admin panel
No description
10 replies
FFilament
Created by jak888 on 3/15/2024 in #❓┊help
Setting the filament default page
I'm getting an error on my production site stating that: No default Filament panel is set. You may do this with the default() method inside a Filament provider's panel() configuration. Error Type: Filament\Exceptions\NoDefaultPanelSetException I never had to set that locally or on my staging site. /admin would just get me to the dashboard. Why do I suddenly have to set this and how do I get the standard behavior? I guess I need to edit the default() method in the AdminPanelProvider.php, but what do I put in there? Also, when looking in the Filament\Resources\DashboardResource folder, it's empty.
21 replies