F
Filament15mo ago
Vp

Include one page on another page and use variables

I've created a Home page using make:filament-page and create another filament page called Stats now I include stats in home like @include('filament.app.pages.stats') And inside Stats, I define variable
class Stats extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected ?string $heading = '';

protected static bool $shouldRegisterNavigation = false;

protected static string $view = 'filament.app.pages.stats';

public $recents = 'abc';
}

// stats.blade.php
{{ $recents }}
class Stats extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected ?string $heading = '';

protected static bool $shouldRegisterNavigation = false;

protected static string $view = 'filament.app.pages.stats';

public $recents = 'abc';
}

// stats.blade.php
{{ $recents }}
But it shows Undefined variable $recents Is my approach is wrong way? how to include another filament page inside filament page
Solution:
I don't think you can load a 'Page' inside a 'Page', they would clash. You could load another LW component in your page though.
Jump to solution
2 Replies
Vp
VpOP15mo ago
If I hit the exact url {host}/stats then it display correctly tho And without the variable, it showing correct.. Bump
Solution
awcodes
awcodes15mo ago
I don't think you can load a 'Page' inside a 'Page', they would clash. You could load another LW component in your page though.
Want results from more Discord servers?
Add your server