A dashboard widget lists what expires in the next two weeks, and a daily command reminds whoever edits it a week and a day ahead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
935 B
PHP
41 lines
935 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Widgets;
|
|
|
|
use App\Support\Expiring;
|
|
use Filament\Widgets\Widget;
|
|
use Illuminate\Support\Collection;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
/**
|
|
* "Coming up": calls closing and content coming off the site in the next two
|
|
* weeks, for whoever can do something about them.
|
|
*/
|
|
class ExpiringSoon extends Widget
|
|
{
|
|
public const DAYS = 14;
|
|
|
|
protected static ?int $sort = 1;
|
|
|
|
protected string $view = 'filament.widgets.expiring-soon';
|
|
|
|
protected int|string|array $columnSpan = 'full';
|
|
|
|
public static function canView(): bool
|
|
{
|
|
$user = Auth::user();
|
|
|
|
return $user !== null && Expiring::for(Expiring::within(self::DAYS), $user)->isNotEmpty();
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, array<string, mixed>>
|
|
*/
|
|
public function items(): Collection
|
|
{
|
|
return Expiring::for(Expiring::within(self::DAYS), Auth::user());
|
|
}
|
|
}
|