How to set the Dashboard columns to 3 using custom widgets

How can I make this 3 columns? <?php namespace App\Filament\Pages; use Filament\Pages\Dashboard as BasePage; class Dashboard extends BasePage { protected function getColumns(): int | array { return 3; } } ?>
No description
12 Replies
DrByte
DrByte2y ago
Yes. Have you tried making that getColumns function public instead of protected?
DrByte
DrByte2y ago
(If you look at the \Filament\Pages\Dashboard class which you're extending, you'll see that it's public there, and you're overriding that) ... https://github.com/filamentphp/filament/blob/f14ec4205db67bf83a02d344fc8e923594676473/packages/panels/src/Pages/Dashboard.php#L67-L73
GitHub
filament/packages/panels/src/Pages/Dashboard.php at f14ec4205db67bf...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament
johny7
johny72y ago
In my case
class Dashboard extends BasePage
{
public function getColumns(): int | string | array
{
return 1;
}

}
class Dashboard extends BasePage
{
public function getColumns(): int | string | array
{
return 1;
}

}
works properly.
toeknee
toeknee2y ago
protected function getColumns(): int|string|array
{
return 3;
}
protected function getColumns(): int|string|array
{
return 3;
}
is correct, are thoes widgets widgets or cards in a widget
toeknee
toeknee2y ago
Ok... so the above will work in the dashboard class.
AngryTestie
AngryTestieOP2y ago
I wonder why it is still not working
toeknee
toeknee2y ago
Did you replace the default dashboard class with your new one in the config as per the docs
AngryTestie
AngryTestieOP2y ago
is this the correct file structure?It is insidre the resources folder before and I move it and it's working but I have this issue now
No description
No description
toeknee
toeknee2y ago
Yes... then you need to map it in the filament config
DrByte
DrByte2y ago
The duplicate is probably because the default config already lists the default dashboard page. Delete that one from your panel config.
Noor
Noor17mo ago
If it still not working try this using only int protected function getColumns(): int { return 3; }

Did you find this page helpful?