Custom Page as a Dashboard Unable to find component: [app.filament.admin.widgets
Hello, folks! đź‘‹
I got this error
Livewire \ Exceptions \ ComponentNotFoundException
PHP 8.2.10
10.26.2
Unable to find component: [app.filament.admin.widgets.stats]
this is my code
DocumentDashboard
document-dashboard.blade.php (view)
<?php
namespace App\Filament\Admin\Pages;
use App\Filament\Admin\Widgets\Stats;
use Filament\Pages\Page;
class DocumentDashboard extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.admin.pages.document-dashboard';
public function getMaxContentWidth(): ?string
{
return 'full';
}
public function getColumns(): int | string | array
{
return [
'md' => 4,
'xl' => 6,
];
}
public function getTitle(): string
{
return __('panel.pages.DocumentStatistics');
}
public static function getNavigationLabel(): string
{
return __('panel.pages.DocumentStatistics');
}
public function getHeading(): string|\Illuminate\Contracts\Support\Htmlable
{
return __('panel.pages.DocumentStatistics');
}
protected static ?int $navigationSort = 0;
public static function getNavigationGroup(): ?string
{
return __('panel.groups.statistics');
}
protected function getWidgets(): array
{
return [
Stats::class,
];
}
public function getVisibleWidgets(): array
{
return $this->filterVisibleWidgets($this->getWidgets());
}
}
<?php
namespace App\Filament\Admin\Pages;
use App\Filament\Admin\Widgets\Stats;
use Filament\Pages\Page;
class DocumentDashboard extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.admin.pages.document-dashboard';
public function getMaxContentWidth(): ?string
{
return 'full';
}
public function getColumns(): int | string | array
{
return [
'md' => 4,
'xl' => 6,
];
}
public function getTitle(): string
{
return __('panel.pages.DocumentStatistics');
}
public static function getNavigationLabel(): string
{
return __('panel.pages.DocumentStatistics');
}
public function getHeading(): string|\Illuminate\Contracts\Support\Htmlable
{
return __('panel.pages.DocumentStatistics');
}
protected static ?int $navigationSort = 0;
public static function getNavigationGroup(): ?string
{
return __('panel.groups.statistics');
}
protected function getWidgets(): array
{
return [
Stats::class,
];
}
public function getVisibleWidgets(): array
{
return $this->filterVisibleWidgets($this->getWidgets());
}
}
<x-filament-panels::page class="fi-dashboard-page">
<x-filament-widgets::widgets
:columns="$this->getColumns()"
:data="$this->getWidgetData()"
:widgets="$this->getVisibleWidgets()"
/>
</x-filament-panels::page>
<x-filament-panels::page class="fi-dashboard-page">
<x-filament-widgets::widgets
:columns="$this->getColumns()"
:data="$this->getWidgetData()"
:widgets="$this->getVisibleWidgets()"
/>
</x-filament-panels::page>
1 Reply
Stats.php
up anyone got this problem or am i missing somthing?
i found a another way and its working fine now
i created custom page for the DocumentRecordResource
and a widgets for that custom page as below
and i added a navigation to that custom page in the AdminServiceProvider like this
hope this help someone
but the other way i think it has a bug
<?php
namespace App\Filament\Admin\Widgets;
use App\Models\Cataloging\DocumentCopy;
use App\Models\Cataloging\DocumentRecord;
use App\Models\Cataloging\Editor;
use App\Models\Circulation\Reader;
use App\Models\Log\ReadersLibraryLog;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
class Stats extends BaseWidget
{
protected static ?int $sort = 1;
protected function getStats(): array
{
return [
Stat::make(__('cruds.documentRecord.title'), number_format(DocumentRecord::count(), 0, ',', ','))
->label(__('global.number') .' '.__('cruds.documentRecord.title'))
->description(__('global.number').__('panel.widgets.PaperDocuments').' : '. number_format(DocumentRecord::where('document_type_id','1')->count(), 0, ',', ','))
->descriptionIcon('heroicon-m-arrow-trending-up')
->chart([7, 2, 10, 3, 15, 4, 17])
->color('warning')
->extraAttributes([
'class' => 'cursor-pointer bg-[radial-gradient(ellipse_at_bottom_left,_var(--tw-gradient-stops))] from-blue-100 via-blue-50 to-orange-200 dark:from-blue-700 dark:via-blue-800 dark:to-gray-900 ',
'wire:click' => "\$dispatch('setStatusFilter', { filter: 'processed' })",
]),
Stat::make(__('global.number') .' '.__('cruds.documentCopy.title'), number_format(DocumentCopy::count(), 0, ',', ','))
->description('7% increase')
->descriptionIcon('heroicon-m-arrow-trending-up')
->chart([7, 2, 10, 3, 15, 4, 17])
->color('success'),
];
}
}
<?php
namespace App\Filament\Admin\Widgets;
use App\Models\Cataloging\DocumentCopy;
use App\Models\Cataloging\DocumentRecord;
use App\Models\Cataloging\Editor;
use App\Models\Circulation\Reader;
use App\Models\Log\ReadersLibraryLog;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
class Stats extends BaseWidget
{
protected static ?int $sort = 1;
protected function getStats(): array
{
return [
Stat::make(__('cruds.documentRecord.title'), number_format(DocumentRecord::count(), 0, ',', ','))
->label(__('global.number') .' '.__('cruds.documentRecord.title'))
->description(__('global.number').__('panel.widgets.PaperDocuments').' : '. number_format(DocumentRecord::where('document_type_id','1')->count(), 0, ',', ','))
->descriptionIcon('heroicon-m-arrow-trending-up')
->chart([7, 2, 10, 3, 15, 4, 17])
->color('warning')
->extraAttributes([
'class' => 'cursor-pointer bg-[radial-gradient(ellipse_at_bottom_left,_var(--tw-gradient-stops))] from-blue-100 via-blue-50 to-orange-200 dark:from-blue-700 dark:via-blue-800 dark:to-gray-900 ',
'wire:click' => "\$dispatch('setStatusFilter', { filter: 'processed' })",
]),
Stat::make(__('global.number') .' '.__('cruds.documentCopy.title'), number_format(DocumentCopy::count(), 0, ',', ','))
->description('7% increase')
->descriptionIcon('heroicon-m-arrow-trending-up')
->chart([7, 2, 10, 3, 15, 4, 17])
->color('success'),
];
}
}
php artisan make:filament-page StatsDocumentRecord --resource=Cataloging/DocumentRecordResource --type=custom
php artisan make:filament-widget DocumentRecordsByYearTable --chart --resource=Cataloging/DocumentRecordResource
php artisan make:filament-page StatsDocumentRecord --resource=Cataloging/DocumentRecordResource --type=custom
php artisan make:filament-widget DocumentRecordsByYearTable --chart --resource=Cataloging/DocumentRecordResource
->navigationItems([
NavigationItem::make('Analytics')
->label(fn () => __('panel.pages.DocumentStatistics'))
->url(fn (): string => StatsDocumentRecord::getUrl())
->icon('heroicon-o-presentation-chart-line')
->group(fn () => __('panel.groups.statistics'))
->sort(0),
])
->navigationItems([
NavigationItem::make('Analytics')
->label(fn () => __('panel.pages.DocumentStatistics'))
->url(fn (): string => StatsDocumentRecord::getUrl())
->icon('heroicon-o-presentation-chart-line')
->group(fn () => __('panel.groups.statistics'))
->sort(0),
])