How to add widgets to default dashboard page.
Hi I am a little confused about how to add the widgets i have created to the defualt page that comes with the admin pannel.
I am struggling to understand were it is defined in the file structure at all.
I have made widgets and can add them to other pages i have created but not been able so far to add this to the defult page.
Thanks in advance
37 Replies
Your dashboard page is defined in your filament config file
So if i define the class of the widget in this list it will show up on the dashboard page?
No, go to the dashboard page that is registered for you
That is why i am confused becuase the pages directory is empty
Any widgets in App\Filament\Widgets will show up on the dashboard automatically. If you widget isnβt in that directory you would add it to the register array there.
It's not there, the default one is in your vendor.. It's defined in your config file..
That's why I told you to go there
It has a widgets function and shows all widget by default but you can overwrite it to your own dashboard page and define yourself what widgets to show.. If your widget is not show automatically it is either
Not in the App\Filament\Widgets namespace (likely)
Or you already have a custom dashboard page where you defined what widgets to show (unlikely)
I really do not understand this reply im sorry, I am more consfued the more times i have read it
Your dashboard page is defined here. You can check what widgets are showing by going to it's location
However the default behavior should be to show all the widgets you have (as long they are in the right namespace)
I created the widget following the steps in the docs, i specified a resource when i ran the command and then i added this to the parent resource
Yeah
Right so my widget must be defined in the name space wrong?
It's not in App\Filament\Widgets
It is in MaterialResource\Widgets\
when i ran the command that is where it put it
Yes π
`
But if you want it to show you would have to put it in App\Filament\Widgets or make a custom dashboard class
Or register it here
Right i am hoping to make the dashbord contents change depending on user type so what do you suggest is the best way to proceed? Make a new custom dashboard type?
When i put the class there it did not show up
Then make a custom page called dashboard
And define it here.. It should replace the default dashboard
When i declare like this it does not find the class
Well you are going to import it
I don't know your ide but I would just delete everything before MaterialWidget::class, hover over and press import π
Like this?
does it work?
no
Yes
it says it cant find the class
Delete Widgets\
Just the name should do
ok it did when i clicked another part of the line
πShould work now then
Sadnly no
This is what the card looks like
It does work.. You just have an error inside your widget π
<x-filament::card>
Not x-filament-cardok that worked, now I just need to sort out this user count variable, which i think i have to define the pick in the pairent resoruce?
Play around with it.. You learn best by doing.. And failing π
π
Thank you for your help, I had to abandon the other tech stack i was using and i have literally a week to learn and publish this project
So i am stressing just a lil bit not like my entire degree is on the line.....
keep calm, it is the only way to think straight.. good luck