Widget blade, white screen

I've seen another post in here but it didn't solve my issue, been trying for a while... this is my blade (resources/views/filament/widgets/property-stats.blade.php):
<x-filament-widgets::widget>
<x-filament::section>
<div>
@livewire(\App\Livewire\PropertyStats::class)
</div>
</x-filament::section>
</x-filament-widgets::widget>
<x-filament-widgets::widget>
<x-filament::section>
<div>
@livewire(\App\Livewire\PropertyStats::class)
</div>
</x-filament::section>
</x-filament-widgets::widget>
php This is my PropertyStats class (App\Livewire):
<?php

namespace App\Livewire;

use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;

class PropertyStats extends BaseWidget
{
protected static string $view = 'filament.widgets.property-stats';

protected static ?string $pollingInterval = null;

protected int | string | array $columnSpan = '6';

protected function getColumns(): int
{
return 3;
}

protected function getStats(): array
{
return [
Stat::make('Regions', '9')
->icon('heroicon-o-map')
->extraAttributes([
'class' => 'cursor-pointer',
// 'wire:click' => "\$dispatch('setStatusFilter', { filter: 'processed' })",
]),

Stat::make('Projects', '3')
->icon('heroicon-o-newspaper'),

Stat::make('Sub Projects', '2')
->icon('heroicon-o-newspaper'),

Stat::make('Total Properties', '131')
->icon('heroicon-o-home-modern'),

Stat::make('Total Properties', '131')
->icon('heroicon-o-home-modern'),
];
}
}
<?php

namespace App\Livewire;

use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;

class PropertyStats extends BaseWidget
{
protected static string $view = 'filament.widgets.property-stats';

protected static ?string $pollingInterval = null;

protected int | string | array $columnSpan = '6';

protected function getColumns(): int
{
return 3;
}

protected function getStats(): array
{
return [
Stat::make('Regions', '9')
->icon('heroicon-o-map')
->extraAttributes([
'class' => 'cursor-pointer',
// 'wire:click' => "\$dispatch('setStatusFilter', { filter: 'processed' })",
]),

Stat::make('Projects', '3')
->icon('heroicon-o-newspaper'),

Stat::make('Sub Projects', '2')
->icon('heroicon-o-newspaper'),

Stat::make('Total Properties', '131')
->icon('heroicon-o-home-modern'),

Stat::make('Total Properties', '131')
->icon('heroicon-o-home-modern'),
];
}
}
php and of course the widget is being called in the panel:
->widgets([
PropertyStats::class,
])
->widgets([
PropertyStats::class,
])
php What shows in the console is an error 500 and the dashboard turns to a white screen.
No description
6 Replies
JJSanders
JJSanders6mo ago
Not sure what you're trying to do but I would look for a php Error. Maybe in the logs
SoraKeyheart
SoraKeyheart6mo ago
The logs show a memory limit error, I've increased it. Im trying to add a title above the widget like this:
No description
Matthew
Matthew6mo ago
I think I might know why this is happening. You are trying to add a widget to a blade file, where the view of the widget is the file itself Therefore you are creating a loop protected static string $view = 'filament.widgets.property-stats'; is the same as the name of the widget you are trying to load it to Its like saying you are trying to load the widget withing the widget
SoraKeyheart
SoraKeyheart6mo ago
Your answer seems logical. It works when I comment out the $view. But this way, the blade won't execute. Also works when I comment out the @livewire in the blade. Any ideas how I can customize the widgets?
Dennis Koch
Dennis Koch6mo ago
You can customize the widget by changing stuff in the view. But it doesn't make any sense to reference the same Livewire component in the view again. You are creating an infinite loop. Just have a look at the view of the original StatsOverviewWidget and copy that as a baseline.
Matthew
Matthew6mo ago
Now you need to reference the widget in your resource or page For Resources
public static function getWidgets(): array
{
return [
CustomerResource\Widgets\CustomerOverview::class,
];
}
public static function getWidgets(): array
{
return [
CustomerResource\Widgets\CustomerOverview::class,
];
}
For Pages
protected function getHeaderWidgets(): array
{
return [
StatsOverviewWidget::class
];
}
protected function getHeaderWidgets(): array
{
return [
StatsOverviewWidget::class
];
}
You customize widgets within the the PropertyStats class