PHP code example of anselmocossa / filament-launchpad
1. Go to this page and download the library: Download anselmocossa/filament-launchpad library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
anselmocossa / filament-launchpad example snippets
use Filament\Launchpad\LaunchpadPlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(LaunchpadPlugin::make());
}
namespace App\Filament\Launchpad;
use App\Models\Order;
use Filament\Launchpad\Launchpad\BaseKpiSource;
use Filament\Launchpad\Launchpad\KpiResult;
class SalesTodayKpi extends BaseKpiSource
{
public function cacheFor(): ?int
{
return 120; // seconds; null = no TTL cache (still memoized once per request)
}
public function resolve(): KpiResult
{
return KpiResult::make(Order::whereDate('created_at', today())->count())
->unit('orders')
->trend('+3 today', 'success') // success | danger | gray
->badge('new'); // pass null to hide the badge
}
}
use Filament\Launchpad\LaunchpadPlugin;
LaunchpadPlugin::make()
->kpis([\App\Filament\Launchpad\SalesTodayKpi::class]) // explicit
->discoverKpis(in: app_path('Metrics'), for: 'App\\Metrics') // custom folder
->autoDiscoverKpis(false); // opt out entirely