Filament moderne (groupes nav, 4 charts, filtres/badges) + Filament Shield (rôles/permissions) + noms exos localisés dans routines
Build & Deploy / build (push) Successful in 19s
Build & Deploy / build (push) Successful in 19s
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Streaks\Pages;
|
||||
|
||||
use App\Filament\Resources\Streaks\StreakResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateStreak extends CreateRecord
|
||||
{
|
||||
protected static string $resource = StreakResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Streaks\Pages;
|
||||
|
||||
use App\Filament\Resources\Streaks\StreakResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditStreak extends EditRecord
|
||||
{
|
||||
protected static string $resource = StreakResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,15 @@
|
||||
namespace App\Filament\Resources\Streaks\Pages;
|
||||
|
||||
use App\Filament\Resources\Streaks\StreakResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListStreaks extends ListRecords
|
||||
{
|
||||
protected static string $resource = StreakResource::class;
|
||||
|
||||
// Streaks calculés par StreakService : aucune action de création manuelle.
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Streaks\Schemas;
|
||||
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class StreakForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('user_id')
|
||||
->relationship('user', 'name')
|
||||
->required(),
|
||||
TextInput::make('current_count')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
TextInput::make('longest_count')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
DatePicker::make('last_active_date'),
|
||||
TextInput::make('freezes_available')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
DatePicker::make('freeze_last_granted_on'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Streaks\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
/**
|
||||
* Fiche de consultation d'un streak (modal "Voir") : calculé par StreakService,
|
||||
* jamais créé ni modifié à la main depuis le back-office.
|
||||
*/
|
||||
class StreakInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('user.name')
|
||||
->label('Utilisateur'),
|
||||
TextEntry::make('current_count')
|
||||
->label('Streak courant')
|
||||
->badge()
|
||||
->color('warning'),
|
||||
TextEntry::make('longest_count')
|
||||
->label('Record')
|
||||
->numeric(),
|
||||
TextEntry::make('freezes_available')
|
||||
->label('Freezes disponibles')
|
||||
->numeric(),
|
||||
TextEntry::make('last_active_date')
|
||||
->label('Dernière activité')
|
||||
->date()
|
||||
->placeholder('—'),
|
||||
TextEntry::make('freeze_last_granted_on')
|
||||
->label('Dernier freeze accordé')
|
||||
->date()
|
||||
->placeholder('—'),
|
||||
TextEntry::make('last_reminded_on')
|
||||
->label('Dernier rappel envoyé')
|
||||
->date()
|
||||
->placeholder('—'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources\Streaks;
|
||||
|
||||
use App\Filament\Resources\Streaks\Pages\CreateStreak;
|
||||
use App\Filament\Resources\Streaks\Pages\EditStreak;
|
||||
use App\Filament\Resources\Streaks\Pages\ListStreaks;
|
||||
use App\Filament\Resources\Streaks\Schemas\StreakForm;
|
||||
use App\Filament\Resources\Streaks\Schemas\StreakInfolist;
|
||||
use App\Filament\Resources\Streaks\Tables\StreaksTable;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
@@ -13,16 +11,30 @@ use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Functional\Streaks\Models\Streak;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* Streaks calculés par StreakService (1 par user) — consultation + suppression uniquement,
|
||||
* jamais de création/édition manuelle depuis le back-office.
|
||||
*/
|
||||
class StreakResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Streak::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedFire;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Gamification';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static ?string $modelLabel = 'streak';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'streaks';
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return StreakForm::configure($schema);
|
||||
return StreakInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
@@ -30,19 +42,28 @@ class StreakResource extends Resource
|
||||
return StreaksTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
public static function canCreate(): bool
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canEdit(Model $record): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function getGloballySearchableAttributes(): array
|
||||
{
|
||||
return ['user.name'];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListStreaks::route('/'),
|
||||
'create' => CreateStreak::route('/create'),
|
||||
'edit' => EditStreak::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
namespace App\Filament\Resources\Streaks\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
/**
|
||||
* Table des streaks : régularité par utilisateur (courant, record, freezes, dernière activité).
|
||||
* Lecture seule + suppression : calculé par StreakService, jamais créé/édité ici.
|
||||
*/
|
||||
class StreaksTable
|
||||
{
|
||||
@@ -33,14 +35,16 @@ class StreaksTable
|
||||
TextColumn::make('freezes_available')
|
||||
->label('Freezes dispo')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('last_active_date')
|
||||
->label('Dernière activité')
|
||||
->date()
|
||||
->sortable(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
ViewAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
|
||||
Reference in New Issue
Block a user