Warn about calls closing and content coming off the site
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>
This commit is contained in:
40
app/Filament/Widgets/ExpiringSoon.php
Normal file
40
app/Filament/Widgets/ExpiringSoon.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user