Looking to improve the user experience of MoonGuard Filament Plugin, we realized that the only way to know when a site is under maintenance is by reviewing its configuration, which motivated us to add an indicator in the "sites stats" of the dashboard, we also contemplated that there was no mechanism that would allow us to eliminate very old exceptions in the database, those that occurred a long time ago and that we could consider as irrelevant information.
In this article we will explore how we add the functionality.
Adding maintenance indicator
Normally we use these site stats to visualize the uptime, ssl-certificate and number of exceptions that our sites have, so we had the idea to improve this by adding an indicator of when the sites are under maintenance.
To achieve this, we update our Filament widget
site-stats-widget.blade.php by adding a conditional
that is executed when there is a date of the
down_for_maintenance_at property of the
We also updated the widget components
item.blade.php so that they are not activated when in maintenance in
order not to confuse us and improve the user experience.
The final result was the following.
These small details are what polish and improve the user experience using MoonGuard.
If you want to see more detailed code you can see the PR on Github.
Add command to clean exceptions
We have a productive MoonGuard in which we have been testing its functionalities for the last 2-3 months with real projects and we realized that we needed a way to clean (automatically) very old exceptions that were no longer relevant, so we decided to create a new command and schedule it in the server scheduler to run periodically.
We created the command
DeleteOldExceptionCommand , where all those exceptions that are older
than the time specified in the MoonGuard configuration are deleted periodically:
class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
This command works similar to the other MoonGuard commands (The
CheckSslCertificateCommand) you can schedule the execution of this command or use the
MoonGuardCommandsScheduler if you want to schedule these three commands:
protected function schedule(Schedule $schedule): void
'* * * * *', // <-- Uptime Check Cron
'* * * * *', //<-- SSL Certificate Check Cron
'* * * * *' //<-- [Optional] Delete Exceptions Cron
For more information on programming these commands you can visit the MoonGuard documentation.
You can also read in detail the related changes in this PR on GitHub.
If you want to learn more about MoonGuard Filament Plugin, we invite you to read our book MoonGuard: The Software Creator's Journey V2 where we talk in detail about how we created each of the MoonGuard features as a Filament v3 plugin.