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:
@@ -2,10 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Achievements;
|
namespace App\Filament\Resources\Achievements;
|
||||||
|
|
||||||
use App\Filament\Resources\Achievements\Pages\CreateAchievement;
|
|
||||||
use App\Filament\Resources\Achievements\Pages\EditAchievement;
|
|
||||||
use App\Filament\Resources\Achievements\Pages\ListAchievements;
|
use App\Filament\Resources\Achievements\Pages\ListAchievements;
|
||||||
use App\Filament\Resources\Achievements\Schemas\AchievementForm;
|
use App\Filament\Resources\Achievements\Schemas\AchievementInfolist;
|
||||||
use App\Filament\Resources\Achievements\Tables\AchievementsTable;
|
use App\Filament\Resources\Achievements\Tables\AchievementsTable;
|
||||||
use BackedEnum;
|
use BackedEnum;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
@@ -13,16 +11,32 @@ use Filament\Schemas\Schema;
|
|||||||
use Filament\Support\Icons\Heroicon;
|
use Filament\Support\Icons\Heroicon;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Functional\Streaks\Models\Achievement;
|
use Functional\Streaks\Models\Achievement;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Badges débloqués par StreakService aux paliers de streak — consultation + suppression
|
||||||
|
* uniquement, jamais de création/édition manuelle depuis le back-office.
|
||||||
|
*/
|
||||||
class AchievementResource extends Resource
|
class AchievementResource extends Resource
|
||||||
{
|
{
|
||||||
protected static ?string $model = Achievement::class;
|
protected static ?string $model = Achievement::class;
|
||||||
|
|
||||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedTrophy;
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
protected static string|UnitEnum|null $navigationGroup = 'Gamification';
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 2;
|
||||||
|
|
||||||
|
protected static ?string $modelLabel = 'badge';
|
||||||
|
|
||||||
|
protected static ?string $pluralModelLabel = 'badges';
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'key';
|
||||||
|
|
||||||
|
public static function infolist(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return AchievementForm::configure($schema);
|
return AchievementInfolist::configure($schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
@@ -30,19 +44,28 @@ class AchievementResource extends Resource
|
|||||||
return AchievementsTable::configure($table);
|
return AchievementsTable::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 ['key', 'user.name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPages(): array
|
public static function getPages(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'index' => ListAchievements::route('/'),
|
'index' => ListAchievements::route('/'),
|
||||||
'create' => CreateAchievement::route('/create'),
|
|
||||||
'edit' => EditAchievement::route('/{record}/edit'),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\Achievements\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\Achievements\AchievementResource;
|
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
|
||||||
|
|
||||||
class CreateAchievement extends CreateRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = AchievementResource::class;
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\Achievements\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\Achievements\AchievementResource;
|
|
||||||
use Filament\Actions\DeleteAction;
|
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditAchievement extends EditRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = AchievementResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
DeleteAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,17 +3,15 @@
|
|||||||
namespace App\Filament\Resources\Achievements\Pages;
|
namespace App\Filament\Resources\Achievements\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\Achievements\AchievementResource;
|
use App\Filament\Resources\Achievements\AchievementResource;
|
||||||
use Filament\Actions\CreateAction;
|
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
class ListAchievements extends ListRecords
|
class ListAchievements extends ListRecords
|
||||||
{
|
{
|
||||||
protected static string $resource = AchievementResource::class;
|
protected static string $resource = AchievementResource::class;
|
||||||
|
|
||||||
|
// Badges posés par StreakService : aucune action de création manuelle.
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [];
|
||||||
CreateAction::make(),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\Achievements\Schemas;
|
|
||||||
|
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
|
||||||
use Filament\Forms\Components\Select;
|
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
use Filament\Schemas\Schema;
|
|
||||||
|
|
||||||
class AchievementForm
|
|
||||||
{
|
|
||||||
public static function configure(Schema $schema): Schema
|
|
||||||
{
|
|
||||||
return $schema
|
|
||||||
->components([
|
|
||||||
Select::make('user_id')
|
|
||||||
->relationship('user', 'name')
|
|
||||||
->required(),
|
|
||||||
TextInput::make('key')
|
|
||||||
->required(),
|
|
||||||
DateTimePicker::make('earned_at')
|
|
||||||
->required(),
|
|
||||||
TextInput::make('meta'),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\Achievements\Schemas;
|
||||||
|
|
||||||
|
use Filament\Infolists\Components\TextEntry;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fiche de consultation d'un badge débloqué (modal "Voir") : posé par StreakService
|
||||||
|
* aux paliers de streak, jamais créé ni modifié à la main depuis le back-office.
|
||||||
|
*/
|
||||||
|
class AchievementInfolist
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
TextEntry::make('user.name')
|
||||||
|
->label('Utilisateur'),
|
||||||
|
TextEntry::make('key')
|
||||||
|
->label('Badge')
|
||||||
|
->badge(),
|
||||||
|
TextEntry::make('earned_at')
|
||||||
|
->label('Obtenu le')
|
||||||
|
->dateTime(),
|
||||||
|
TextEntry::make('meta')
|
||||||
|
->label('Métadonnées')
|
||||||
|
->columnSpanFull()
|
||||||
|
->placeholder('—'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,13 +3,18 @@
|
|||||||
namespace App\Filament\Resources\Achievements\Tables;
|
namespace App\Filament\Resources\Achievements\Tables;
|
||||||
|
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteAction;
|
||||||
use Filament\Actions\DeleteBulkAction;
|
use Filament\Actions\DeleteBulkAction;
|
||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\ViewAction;
|
||||||
|
use Filament\Forms\Components\DatePicker;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table des badges débloqués : utilisateur, clé du badge, date d'obtention.
|
* Table des badges débloqués : utilisateur, clé du badge, date d'obtention.
|
||||||
|
* Lecture seule + suppression : posé par StreakService, jamais créé/édité ici.
|
||||||
*/
|
*/
|
||||||
class AchievementsTable
|
class AchievementsTable
|
||||||
{
|
{
|
||||||
@@ -24,14 +29,29 @@ class AchievementsTable
|
|||||||
TextColumn::make('key')
|
TextColumn::make('key')
|
||||||
->label('Badge')
|
->label('Badge')
|
||||||
->badge()
|
->badge()
|
||||||
->searchable(),
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
TextColumn::make('earned_at')
|
TextColumn::make('earned_at')
|
||||||
->label('Obtenu le')
|
->label('Obtenu le')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
])
|
])
|
||||||
|
->filters([
|
||||||
|
Filter::make('earned_at')
|
||||||
|
->label('Période')
|
||||||
|
->schema([
|
||||||
|
DatePicker::make('from')->label('Du'),
|
||||||
|
DatePicker::make('until')->label('Au'),
|
||||||
|
])
|
||||||
|
->query(function (Builder $query, array $data): Builder {
|
||||||
|
return $query
|
||||||
|
->when($data['from'] ?? null, fn (Builder $q, string $date): Builder => $q->whereDate('earned_at', '>=', $date))
|
||||||
|
->when($data['until'] ?? null, fn (Builder $q, string $date): Builder => $q->whereDate('earned_at', '<=', $date));
|
||||||
|
}),
|
||||||
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
EditAction::make(),
|
ViewAction::make(),
|
||||||
|
DeleteAction::make(),
|
||||||
])
|
])
|
||||||
->toolbarActions([
|
->toolbarActions([
|
||||||
BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ class ExerciseResource extends Resource
|
|||||||
|
|
||||||
protected static string|UnitEnum|null $navigationGroup = 'Catalogue';
|
protected static string|UnitEnum|null $navigationGroup = 'Catalogue';
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 1;
|
||||||
|
|
||||||
protected static ?string $modelLabel = 'exercice';
|
protected static ?string $modelLabel = 'exercice';
|
||||||
|
|
||||||
protected static ?string $pluralModelLabel = 'exercices';
|
protected static ?string $pluralModelLabel = 'exercices';
|
||||||
@@ -47,6 +49,14 @@ class ExerciseResource extends Resource
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public static function getGloballySearchableAttributes(): array
|
||||||
|
{
|
||||||
|
return ['name', 'category', 'body_part', 'target'];
|
||||||
|
}
|
||||||
|
|
||||||
public static function getPages(): array
|
public static function getPages(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -25,18 +25,28 @@ class ExercisesTable
|
|||||||
->label('Nom')
|
->label('Nom')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
TextColumn::make('category')
|
||||||
|
->label('Catégorie')
|
||||||
|
->badge()
|
||||||
|
->color('gray')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('body_part')
|
TextColumn::make('body_part')
|
||||||
->label('Partie du corps')
|
->label('Partie du corps')
|
||||||
->badge()
|
->badge()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
TextColumn::make('equipment')
|
TextColumn::make('equipment')
|
||||||
->label('Équipement')
|
->label('Équipement')
|
||||||
->badge(),
|
->badge()
|
||||||
|
->toggleable(),
|
||||||
TextColumn::make('target')
|
TextColumn::make('target')
|
||||||
->label('Muscle cible')
|
->label('Muscle cible')
|
||||||
->badge(),
|
->badge(),
|
||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
|
SelectFilter::make('category')
|
||||||
|
->label('Catégorie')
|
||||||
|
->options(fn (): array => self::distinctOptions('category')),
|
||||||
SelectFilter::make('body_part')
|
SelectFilter::make('body_part')
|
||||||
->label('Partie du corps')
|
->label('Partie du corps')
|
||||||
->options(fn (): array => self::distinctOptions('body_part')),
|
->options(fn (): array => self::distinctOptions('body_part')),
|
||||||
|
|||||||
@@ -13,12 +13,21 @@ use Filament\Schemas\Schema;
|
|||||||
use Filament\Support\Icons\Heroicon;
|
use Filament\Support\Icons\Heroicon;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Technical\Integrations\Models\Integration;
|
use Technical\Integrations\Models\Integration;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
class IntegrationResource extends Resource
|
class IntegrationResource extends Resource
|
||||||
{
|
{
|
||||||
protected static ?string $model = Integration::class;
|
protected static ?string $model = Integration::class;
|
||||||
|
|
||||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedArrowsRightLeft;
|
||||||
|
|
||||||
|
protected static string|UnitEnum|null $navigationGroup = 'Système';
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 1;
|
||||||
|
|
||||||
|
protected static ?string $modelLabel = 'intégration';
|
||||||
|
|
||||||
|
protected static ?string $pluralModelLabel = 'intégrations';
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
public static function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
@@ -37,6 +46,14 @@ class IntegrationResource extends Resource
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public static function getGloballySearchableAttributes(): array
|
||||||
|
{
|
||||||
|
return ['provider', 'external_user_id', 'user.name'];
|
||||||
|
}
|
||||||
|
|
||||||
public static function getPages(): array
|
public static function getPages(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -2,13 +2,17 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Integrations\Tables;
|
namespace App\Filament\Resources\Integrations\Tables;
|
||||||
|
|
||||||
|
use Filament\Actions\BulkAction;
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
use Filament\Actions\DeleteBulkAction;
|
use Filament\Actions\DeleteBulkAction;
|
||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Filters\SelectFilter;
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Technical\Integrations\Enums\IntegrationStatus;
|
use Technical\Integrations\Enums\IntegrationStatus;
|
||||||
|
use Technical\Integrations\Models\Integration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table des intégrations externes : utilisateur, fournisseur, état, dernière synchro.
|
* Table des intégrations externes : utilisateur, fournisseur, état, dernière synchro.
|
||||||
@@ -27,7 +31,17 @@ class IntegrationsTable
|
|||||||
TextColumn::make('provider')
|
TextColumn::make('provider')
|
||||||
->label('Fournisseur')
|
->label('Fournisseur')
|
||||||
->badge()
|
->badge()
|
||||||
->searchable(),
|
->color(fn (string $state): string => match (strtolower($state)) {
|
||||||
|
'strava' => 'danger',
|
||||||
|
'garmin' => 'info',
|
||||||
|
default => 'gray',
|
||||||
|
})
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
TextColumn::make('external_user_id')
|
||||||
|
->label('ID externe')
|
||||||
|
->toggleable(isToggledHiddenByDefault: true)
|
||||||
|
->placeholder('—'),
|
||||||
TextColumn::make('status')
|
TextColumn::make('status')
|
||||||
->label('État')
|
->label('État')
|
||||||
->badge()
|
->badge()
|
||||||
@@ -36,6 +50,11 @@ class IntegrationsTable
|
|||||||
IntegrationStatus::Revoked => 'gray',
|
IntegrationStatus::Revoked => 'gray',
|
||||||
IntegrationStatus::Error => 'danger',
|
IntegrationStatus::Error => 'danger',
|
||||||
}),
|
}),
|
||||||
|
TextColumn::make('connected_at')
|
||||||
|
->label('Connecté le')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('last_synced_at')
|
TextColumn::make('last_synced_at')
|
||||||
->label('Dernière synchro')
|
->label('Dernière synchro')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
@@ -43,6 +62,9 @@ class IntegrationsTable
|
|||||||
->placeholder('Jamais'),
|
->placeholder('Jamais'),
|
||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
|
SelectFilter::make('provider')
|
||||||
|
->label('Fournisseur')
|
||||||
|
->options(fn (): array => self::distinctProviders()),
|
||||||
SelectFilter::make('status')
|
SelectFilter::make('status')
|
||||||
->label('État')
|
->label('État')
|
||||||
->options(IntegrationStatus::class),
|
->options(IntegrationStatus::class),
|
||||||
@@ -53,8 +75,34 @@ class IntegrationsTable
|
|||||||
->toolbarActions([
|
->toolbarActions([
|
||||||
BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
DeleteBulkAction::make(),
|
DeleteBulkAction::make(),
|
||||||
|
// Révocation groupée : coupe l'accès sans supprimer l'historique de connexion.
|
||||||
|
BulkAction::make('revoke')
|
||||||
|
->label('Révoquer')
|
||||||
|
->icon(Heroicon::OutlinedBoltSlash)
|
||||||
|
->color('danger')
|
||||||
|
->requiresConfirmation()
|
||||||
|
->action(function (Collection $records): void {
|
||||||
|
$records->each(fn (Integration $integration) => $integration->update([
|
||||||
|
'status' => IntegrationStatus::Revoked,
|
||||||
|
]));
|
||||||
|
})
|
||||||
|
->deselectRecordsAfterCompletion(),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
->defaultSort('last_synced_at', 'desc');
|
->defaultSort('last_synced_at', 'desc');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valeurs distinctes de la colonne "provider" pour alimenter le filtre.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
private static function distinctProviders(): array
|
||||||
|
{
|
||||||
|
return Integration::query()
|
||||||
|
->distinct()
|
||||||
|
->orderBy('provider')
|
||||||
|
->pluck('provider', 'provider')
|
||||||
|
->all();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,12 +13,23 @@ use Filament\Schemas\Schema;
|
|||||||
use Filament\Support\Icons\Heroicon;
|
use Filament\Support\Icons\Heroicon;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Functional\Programs\Models\Program;
|
use Functional\Programs\Models\Program;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
class ProgramResource extends Resource
|
class ProgramResource extends Resource
|
||||||
{
|
{
|
||||||
protected static ?string $model = Program::class;
|
protected static ?string $model = Program::class;
|
||||||
|
|
||||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCalendarDays;
|
||||||
|
|
||||||
|
protected static string|UnitEnum|null $navigationGroup = 'Entraînement';
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 2;
|
||||||
|
|
||||||
|
protected static ?string $modelLabel = 'programme';
|
||||||
|
|
||||||
|
protected static ?string $pluralModelLabel = 'programmes';
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'name';
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
public static function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
@@ -37,6 +48,14 @@ class ProgramResource extends Resource
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public static function getGloballySearchableAttributes(): array
|
||||||
|
{
|
||||||
|
return ['name', 'slug', 'user.name'];
|
||||||
|
}
|
||||||
|
|
||||||
public static function getPages(): array
|
public static function getPages(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
namespace App\Filament\Resources\Programs\Schemas;
|
namespace App\Filament\Resources\Programs\Schemas;
|
||||||
|
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
use Filament\Forms\Components\Textarea;
|
use Filament\Forms\Components\Textarea;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Components\Toggle;
|
use Filament\Forms\Components\Toggle;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ use Filament\Actions\DeleteBulkAction;
|
|||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\EditAction;
|
||||||
use Filament\Tables\Columns\IconColumn;
|
use Filament\Tables\Columns\IconColumn;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
|
use Filament\Tables\Filters\TernaryFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,6 +32,11 @@ class ProgramsTable
|
|||||||
->label('Semaines')
|
->label('Semaines')
|
||||||
->numeric()
|
->numeric()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
TextColumn::make('days_per_week')
|
||||||
|
->label('Jours / semaine')
|
||||||
|
->numeric()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
IconColumn::make('is_public')
|
IconColumn::make('is_public')
|
||||||
->label('Public')
|
->label('Public')
|
||||||
->boolean(),
|
->boolean(),
|
||||||
@@ -38,6 +45,16 @@ class ProgramsTable
|
|||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
])
|
])
|
||||||
|
->filters([
|
||||||
|
TernaryFilter::make('is_public')
|
||||||
|
->label('Visibilité')
|
||||||
|
->trueLabel('Publics')
|
||||||
|
->falseLabel('Privés'),
|
||||||
|
SelectFilter::make('user')
|
||||||
|
->label('Utilisateur')
|
||||||
|
->relationship('user', 'name')
|
||||||
|
->searchable(),
|
||||||
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
EditAction::make(),
|
EditAction::make(),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -13,12 +13,23 @@ use Filament\Schemas\Schema;
|
|||||||
use Filament\Support\Icons\Heroicon;
|
use Filament\Support\Icons\Heroicon;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Functional\Routines\Models\Routine;
|
use Functional\Routines\Models\Routine;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
class RoutineResource extends Resource
|
class RoutineResource extends Resource
|
||||||
{
|
{
|
||||||
protected static ?string $model = Routine::class;
|
protected static ?string $model = Routine::class;
|
||||||
|
|
||||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedClipboardDocumentList;
|
||||||
|
|
||||||
|
protected static string|UnitEnum|null $navigationGroup = 'Entraînement';
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 1;
|
||||||
|
|
||||||
|
protected static ?string $modelLabel = 'routine';
|
||||||
|
|
||||||
|
protected static ?string $pluralModelLabel = 'routines';
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'name';
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
public static function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
@@ -37,6 +48,14 @@ class RoutineResource extends Resource
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public static function getGloballySearchableAttributes(): array
|
||||||
|
{
|
||||||
|
return ['name', 'slug', 'user.name'];
|
||||||
|
}
|
||||||
|
|
||||||
public static function getPages(): array
|
public static function getPages(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
namespace App\Filament\Resources\Routines\Schemas;
|
namespace App\Filament\Resources\Routines\Schemas;
|
||||||
|
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
use Filament\Forms\Components\Textarea;
|
use Filament\Forms\Components\Textarea;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Components\Toggle;
|
use Filament\Forms\Components\Toggle;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ use Filament\Actions\DeleteBulkAction;
|
|||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\EditAction;
|
||||||
use Filament\Tables\Columns\IconColumn;
|
use Filament\Tables\Columns\IconColumn;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
|
use Filament\Tables\Filters\TernaryFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,6 +28,11 @@ class RoutinesTable
|
|||||||
->label('Utilisateur')
|
->label('Utilisateur')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
TextColumn::make('estimated_minutes')
|
||||||
|
->label('Durée (min)')
|
||||||
|
->numeric()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
IconColumn::make('is_public')
|
IconColumn::make('is_public')
|
||||||
->label('Publique')
|
->label('Publique')
|
||||||
->boolean(),
|
->boolean(),
|
||||||
@@ -34,6 +41,16 @@ class RoutinesTable
|
|||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
])
|
])
|
||||||
|
->filters([
|
||||||
|
TernaryFilter::make('is_public')
|
||||||
|
->label('Visibilité')
|
||||||
|
->trueLabel('Publiques')
|
||||||
|
->falseLabel('Privées'),
|
||||||
|
SelectFilter::make('user')
|
||||||
|
->label('Utilisateur')
|
||||||
|
->relationship('user', 'name')
|
||||||
|
->searchable(),
|
||||||
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
EditAction::make(),
|
EditAction::make(),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -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;
|
namespace App\Filament\Resources\Streaks\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\Streaks\StreakResource;
|
use App\Filament\Resources\Streaks\StreakResource;
|
||||||
use Filament\Actions\CreateAction;
|
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
class ListStreaks extends ListRecords
|
class ListStreaks extends ListRecords
|
||||||
{
|
{
|
||||||
protected static string $resource = StreakResource::class;
|
protected static string $resource = StreakResource::class;
|
||||||
|
|
||||||
|
// Streaks calculés par StreakService : aucune action de création manuelle.
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [];
|
||||||
CreateAction::make(),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
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\Pages\ListStreaks;
|
||||||
use App\Filament\Resources\Streaks\Schemas\StreakForm;
|
use App\Filament\Resources\Streaks\Schemas\StreakInfolist;
|
||||||
use App\Filament\Resources\Streaks\Tables\StreaksTable;
|
use App\Filament\Resources\Streaks\Tables\StreaksTable;
|
||||||
use BackedEnum;
|
use BackedEnum;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
@@ -13,16 +11,30 @@ use Filament\Schemas\Schema;
|
|||||||
use Filament\Support\Icons\Heroicon;
|
use Filament\Support\Icons\Heroicon;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Functional\Streaks\Models\Streak;
|
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
|
class StreakResource extends Resource
|
||||||
{
|
{
|
||||||
protected static ?string $model = Streak::class;
|
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
|
public static function table(Table $table): Table
|
||||||
@@ -30,19 +42,28 @@ class StreakResource extends Resource
|
|||||||
return StreaksTable::configure($table);
|
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
|
public static function getPages(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'index' => ListStreaks::route('/'),
|
'index' => ListStreaks::route('/'),
|
||||||
'create' => CreateStreak::route('/create'),
|
|
||||||
'edit' => EditStreak::route('/{record}/edit'),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,15 @@
|
|||||||
namespace App\Filament\Resources\Streaks\Tables;
|
namespace App\Filament\Resources\Streaks\Tables;
|
||||||
|
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteAction;
|
||||||
use Filament\Actions\DeleteBulkAction;
|
use Filament\Actions\DeleteBulkAction;
|
||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\ViewAction;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table des streaks : régularité par utilisateur (courant, record, freezes, dernière activité).
|
* 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
|
class StreaksTable
|
||||||
{
|
{
|
||||||
@@ -33,14 +35,16 @@ class StreaksTable
|
|||||||
TextColumn::make('freezes_available')
|
TextColumn::make('freezes_available')
|
||||||
->label('Freezes dispo')
|
->label('Freezes dispo')
|
||||||
->numeric()
|
->numeric()
|
||||||
->sortable(),
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('last_active_date')
|
TextColumn::make('last_active_date')
|
||||||
->label('Dernière activité')
|
->label('Dernière activité')
|
||||||
->date()
|
->date()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
])
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
EditAction::make(),
|
ViewAction::make(),
|
||||||
|
DeleteAction::make(),
|
||||||
])
|
])
|
||||||
->toolbarActions([
|
->toolbarActions([
|
||||||
BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
|
|||||||
@@ -15,25 +15,46 @@ class UserForm
|
|||||||
return $schema
|
return $schema
|
||||||
->components([
|
->components([
|
||||||
TextInput::make('name')
|
TextInput::make('name')
|
||||||
|
->label('Nom')
|
||||||
->required(),
|
->required(),
|
||||||
TextInput::make('email')
|
TextInput::make('email')
|
||||||
->label('Email address')
|
->label('Email')
|
||||||
->email()
|
->email()
|
||||||
->required(),
|
->required(),
|
||||||
DateTimePicker::make('email_verified_at'),
|
DateTimePicker::make('email_verified_at')
|
||||||
|
->label('Email vérifié le'),
|
||||||
|
// Requis à la création, laissé vide à l'édition pour ne pas écraser le mot de passe
|
||||||
|
// existant (le cast 'hashed' du modèle User se charge du hachage à la sauvegarde).
|
||||||
TextInput::make('password')
|
TextInput::make('password')
|
||||||
|
->label('Mot de passe')
|
||||||
->password()
|
->password()
|
||||||
->required(),
|
->revealable()
|
||||||
|
->required(fn (string $operation): bool => $operation === 'create')
|
||||||
|
->dehydrated(fn (?string $state): bool => filled($state))
|
||||||
|
->dehydrateStateUsing(fn (?string $state): ?string => filled($state) ? $state : null),
|
||||||
TextInput::make('locale')
|
TextInput::make('locale')
|
||||||
|
->label('Langue')
|
||||||
->required()
|
->required()
|
||||||
->default('fr'),
|
->default('fr'),
|
||||||
Select::make('units')
|
Select::make('units')
|
||||||
|
->label('Unités')
|
||||||
->options(Units::class)
|
->options(Units::class)
|
||||||
->default('metric')
|
->default('metric')
|
||||||
->required(),
|
->required(),
|
||||||
TextInput::make('timezone'),
|
TextInput::make('timezone')
|
||||||
TextInput::make('avatar_path'),
|
->label('Fuseau horaire'),
|
||||||
TextInput::make('oidc_sub'),
|
TextInput::make('avatar_path')
|
||||||
|
->label('Avatar (chemin)'),
|
||||||
|
TextInput::make('oidc_sub')
|
||||||
|
->label('Identifiant OIDC'),
|
||||||
|
// Assignation des rôles Spatie (guard 'web') : pilote l'accès au back-office.
|
||||||
|
Select::make('roles')
|
||||||
|
->label('Rôles')
|
||||||
|
->relationship('roles', 'name')
|
||||||
|
->multiple()
|
||||||
|
->preload()
|
||||||
|
->searchable()
|
||||||
|
->columnSpanFull(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,22 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Users\Tables;
|
namespace App\Filament\Resources\Users\Tables;
|
||||||
|
|
||||||
|
use Filament\Actions\BulkAction;
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
use Filament\Actions\DeleteBulkAction;
|
use Filament\Actions\DeleteBulkAction;
|
||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
|
use Filament\Tables\Filters\TernaryFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
use Functional\Users\Enums\Units;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table des utilisateurs : identité, préférences d'affichage, date d'inscription.
|
* Table des utilisateurs : identité, rôles, préférences d'affichage, date d'inscription.
|
||||||
*/
|
*/
|
||||||
class UsersTable
|
class UsersTable
|
||||||
{
|
{
|
||||||
@@ -25,23 +33,59 @@ class UsersTable
|
|||||||
->label('Email')
|
->label('Email')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
TextColumn::make('roles.name')
|
||||||
|
->label('Rôles')
|
||||||
|
->badge()
|
||||||
|
->color('primary'),
|
||||||
TextColumn::make('locale')
|
TextColumn::make('locale')
|
||||||
->label('Langue')
|
->label('Langue')
|
||||||
->badge(),
|
->badge()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('units')
|
TextColumn::make('units')
|
||||||
->label('Unités')
|
->label('Unités')
|
||||||
->badge(),
|
->badge(),
|
||||||
|
TextColumn::make('email_verified_at')
|
||||||
|
->label('Email vérifié')
|
||||||
|
->dateTime()
|
||||||
|
->placeholder('Non vérifié')
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('created_at')
|
TextColumn::make('created_at')
|
||||||
->label('Inscrit le')
|
->label('Inscrit le')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
])
|
])
|
||||||
|
->filters([
|
||||||
|
SelectFilter::make('roles')
|
||||||
|
->label('Rôle')
|
||||||
|
->relationship('roles', 'name'),
|
||||||
|
SelectFilter::make('units')
|
||||||
|
->label('Unités')
|
||||||
|
->options(Units::class),
|
||||||
|
TernaryFilter::make('email_verified_at')
|
||||||
|
->label('Email vérifié')
|
||||||
|
->nullable(),
|
||||||
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
EditAction::make(),
|
EditAction::make(),
|
||||||
])
|
])
|
||||||
->toolbarActions([
|
->toolbarActions([
|
||||||
BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
DeleteBulkAction::make(),
|
DeleteBulkAction::make(),
|
||||||
|
// Assignation groupée d'un rôle Spatie sans repasser par chaque fiche.
|
||||||
|
BulkAction::make('assignRole')
|
||||||
|
->label('Assigner un rôle')
|
||||||
|
->icon(Heroicon::OutlinedShieldCheck)
|
||||||
|
->color('primary')
|
||||||
|
->schema([
|
||||||
|
Select::make('role')
|
||||||
|
->label('Rôle')
|
||||||
|
->options(fn (): array => Role::query()->pluck('name', 'name')->all())
|
||||||
|
->required(),
|
||||||
|
])
|
||||||
|
->action(function (Collection $records, array $data): void {
|
||||||
|
$records->each(fn ($user) => $user->assignRole($data['role']));
|
||||||
|
})
|
||||||
|
->deselectRecordsAfterCompletion(),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
->defaultSort('created_at', 'desc');
|
->defaultSort('created_at', 'desc');
|
||||||
|
|||||||
@@ -13,12 +13,23 @@ use Filament\Schemas\Schema;
|
|||||||
use Filament\Support\Icons\Heroicon;
|
use Filament\Support\Icons\Heroicon;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Functional\Users\Models\User;
|
use Functional\Users\Models\User;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
class UserResource extends Resource
|
class UserResource extends Resource
|
||||||
{
|
{
|
||||||
protected static ?string $model = User::class;
|
protected static ?string $model = User::class;
|
||||||
|
|
||||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedUsers;
|
||||||
|
|
||||||
|
protected static string|UnitEnum|null $navigationGroup = 'Communauté';
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 1;
|
||||||
|
|
||||||
|
protected static ?string $modelLabel = 'utilisateur';
|
||||||
|
|
||||||
|
protected static ?string $pluralModelLabel = 'utilisateurs';
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'name';
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
public static function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
@@ -37,6 +48,14 @@ class UserResource extends Resource
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public static function getGloballySearchableAttributes(): array
|
||||||
|
{
|
||||||
|
return ['name', 'email'];
|
||||||
|
}
|
||||||
|
|
||||||
public static function getPages(): array
|
public static function getPages(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\WorkoutSessions\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\WorkoutSessions\WorkoutSessionResource;
|
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
|
||||||
|
|
||||||
class CreateWorkoutSession extends CreateRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = WorkoutSessionResource::class;
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\WorkoutSessions\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\WorkoutSessions\WorkoutSessionResource;
|
|
||||||
use Filament\Actions\DeleteAction;
|
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditWorkoutSession extends EditRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = WorkoutSessionResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
DeleteAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,17 +3,15 @@
|
|||||||
namespace App\Filament\Resources\WorkoutSessions\Pages;
|
namespace App\Filament\Resources\WorkoutSessions\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\WorkoutSessions\WorkoutSessionResource;
|
use App\Filament\Resources\WorkoutSessions\WorkoutSessionResource;
|
||||||
use Filament\Actions\CreateAction;
|
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
class ListWorkoutSessions extends ListRecords
|
class ListWorkoutSessions extends ListRecords
|
||||||
{
|
{
|
||||||
protected static string $resource = WorkoutSessionResource::class;
|
protected static string $resource = WorkoutSessionResource::class;
|
||||||
|
|
||||||
|
// Séances loguées par l'app : aucune action de création manuelle.
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [];
|
||||||
CreateAction::make(),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\WorkoutSessions\Schemas;
|
|
||||||
|
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
|
||||||
use Filament\Forms\Components\Select;
|
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
use Filament\Forms\Components\Textarea;
|
|
||||||
use Filament\Schemas\Schema;
|
|
||||||
use Functional\Tracking\Enums\WorkoutSessionStatus;
|
|
||||||
|
|
||||||
class WorkoutSessionForm
|
|
||||||
{
|
|
||||||
public static function configure(Schema $schema): Schema
|
|
||||||
{
|
|
||||||
return $schema
|
|
||||||
->components([
|
|
||||||
Select::make('user_id')
|
|
||||||
->relationship('user', 'name')
|
|
||||||
->required(),
|
|
||||||
Select::make('routine_id')
|
|
||||||
->relationship('routine', 'name'),
|
|
||||||
Select::make('program_id')
|
|
||||||
->relationship('program', 'name'),
|
|
||||||
TextInput::make('title'),
|
|
||||||
DateTimePicker::make('started_at')
|
|
||||||
->required(),
|
|
||||||
DateTimePicker::make('ended_at'),
|
|
||||||
Select::make('status')
|
|
||||||
->options(WorkoutSessionStatus::class)
|
|
||||||
->default('active')
|
|
||||||
->required(),
|
|
||||||
Textarea::make('notes')
|
|
||||||
->columnSpanFull(),
|
|
||||||
TextInput::make('total_volume')
|
|
||||||
->numeric(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\WorkoutSessions\Schemas;
|
||||||
|
|
||||||
|
use Filament\Infolists\Components\TextEntry;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Functional\Tracking\Enums\WorkoutSessionStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fiche de consultation d'une séance (modal "Voir") : données loguées par l'utilisateur/l'app,
|
||||||
|
* jamais créées ni modifiées à la main depuis le back-office.
|
||||||
|
*/
|
||||||
|
class WorkoutSessionInfolist
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
TextEntry::make('user.name')
|
||||||
|
->label('Utilisateur'),
|
||||||
|
TextEntry::make('title')
|
||||||
|
->label('Titre')
|
||||||
|
->placeholder('—'),
|
||||||
|
TextEntry::make('routine.name')
|
||||||
|
->label('Routine')
|
||||||
|
->placeholder('—'),
|
||||||
|
TextEntry::make('program.name')
|
||||||
|
->label('Programme')
|
||||||
|
->placeholder('—'),
|
||||||
|
TextEntry::make('status')
|
||||||
|
->label('Statut')
|
||||||
|
->badge()
|
||||||
|
->color(fn (WorkoutSessionStatus $state): string => match ($state) {
|
||||||
|
WorkoutSessionStatus::Active => 'warning',
|
||||||
|
WorkoutSessionStatus::Completed => 'success',
|
||||||
|
WorkoutSessionStatus::Abandoned => 'danger',
|
||||||
|
}),
|
||||||
|
TextEntry::make('started_at')
|
||||||
|
->label('Débutée le')
|
||||||
|
->dateTime(),
|
||||||
|
TextEntry::make('ended_at')
|
||||||
|
->label('Terminée le')
|
||||||
|
->dateTime()
|
||||||
|
->placeholder('—'),
|
||||||
|
TextEntry::make('total_volume')
|
||||||
|
->label('Volume total')
|
||||||
|
->numeric()
|
||||||
|
->placeholder('—'),
|
||||||
|
TextEntry::make('notes')
|
||||||
|
->label('Notes')
|
||||||
|
->columnSpanFull()
|
||||||
|
->placeholder('—'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,15 +3,20 @@
|
|||||||
namespace App\Filament\Resources\WorkoutSessions\Tables;
|
namespace App\Filament\Resources\WorkoutSessions\Tables;
|
||||||
|
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteAction;
|
||||||
use Filament\Actions\DeleteBulkAction;
|
use Filament\Actions\DeleteBulkAction;
|
||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\ViewAction;
|
||||||
|
use Filament\Forms\Components\DatePicker;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
use Filament\Tables\Filters\SelectFilter;
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Functional\Tracking\Enums\WorkoutSessionStatus;
|
use Functional\Tracking\Enums\WorkoutSessionStatus;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table des séances : utilisateur, statut, début, volume total.
|
* Table des séances : utilisateur, statut, début, volume total.
|
||||||
|
* Lecture seule + suppression : les séances sont loguées par l'app, jamais créées/éditées ici.
|
||||||
*/
|
*/
|
||||||
class WorkoutSessionsTable
|
class WorkoutSessionsTable
|
||||||
{
|
{
|
||||||
@@ -23,6 +28,11 @@ class WorkoutSessionsTable
|
|||||||
->label('Utilisateur')
|
->label('Utilisateur')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
TextColumn::make('title')
|
||||||
|
->label('Titre')
|
||||||
|
->searchable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true)
|
||||||
|
->placeholder('—'),
|
||||||
TextColumn::make('status')
|
TextColumn::make('status')
|
||||||
->label('Statut')
|
->label('Statut')
|
||||||
->badge()
|
->badge()
|
||||||
@@ -38,15 +48,28 @@ class WorkoutSessionsTable
|
|||||||
TextColumn::make('total_volume')
|
TextColumn::make('total_volume')
|
||||||
->label('Volume total')
|
->label('Volume total')
|
||||||
->numeric()
|
->numeric()
|
||||||
->sortable(),
|
->sortable()
|
||||||
|
->placeholder('—'),
|
||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
SelectFilter::make('status')
|
SelectFilter::make('status')
|
||||||
->label('Statut')
|
->label('Statut')
|
||||||
->options(WorkoutSessionStatus::class),
|
->options(WorkoutSessionStatus::class),
|
||||||
|
Filter::make('started_at')
|
||||||
|
->label('Période')
|
||||||
|
->schema([
|
||||||
|
DatePicker::make('from')->label('Du'),
|
||||||
|
DatePicker::make('until')->label('Au'),
|
||||||
|
])
|
||||||
|
->query(function (Builder $query, array $data): Builder {
|
||||||
|
return $query
|
||||||
|
->when($data['from'] ?? null, fn (Builder $q, string $date): Builder => $q->whereDate('started_at', '>=', $date))
|
||||||
|
->when($data['until'] ?? null, fn (Builder $q, string $date): Builder => $q->whereDate('started_at', '<=', $date));
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
EditAction::make(),
|
ViewAction::make(),
|
||||||
|
DeleteAction::make(),
|
||||||
])
|
])
|
||||||
->toolbarActions([
|
->toolbarActions([
|
||||||
BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
|
|||||||
@@ -2,10 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\WorkoutSessions;
|
namespace App\Filament\Resources\WorkoutSessions;
|
||||||
|
|
||||||
use App\Filament\Resources\WorkoutSessions\Pages\CreateWorkoutSession;
|
|
||||||
use App\Filament\Resources\WorkoutSessions\Pages\EditWorkoutSession;
|
|
||||||
use App\Filament\Resources\WorkoutSessions\Pages\ListWorkoutSessions;
|
use App\Filament\Resources\WorkoutSessions\Pages\ListWorkoutSessions;
|
||||||
use App\Filament\Resources\WorkoutSessions\Schemas\WorkoutSessionForm;
|
use App\Filament\Resources\WorkoutSessions\Schemas\WorkoutSessionInfolist;
|
||||||
use App\Filament\Resources\WorkoutSessions\Tables\WorkoutSessionsTable;
|
use App\Filament\Resources\WorkoutSessions\Tables\WorkoutSessionsTable;
|
||||||
use BackedEnum;
|
use BackedEnum;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
@@ -13,16 +11,32 @@ use Filament\Schemas\Schema;
|
|||||||
use Filament\Support\Icons\Heroicon;
|
use Filament\Support\Icons\Heroicon;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Functional\Tracking\Models\WorkoutSession;
|
use Functional\Tracking\Models\WorkoutSession;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Séances loguées par les utilisateurs (via l'app) — consultation + suppression uniquement,
|
||||||
|
* jamais de création/édition manuelle depuis le back-office.
|
||||||
|
*/
|
||||||
class WorkoutSessionResource extends Resource
|
class WorkoutSessionResource extends Resource
|
||||||
{
|
{
|
||||||
protected static ?string $model = WorkoutSession::class;
|
protected static ?string $model = WorkoutSession::class;
|
||||||
|
|
||||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedBolt;
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
protected static string|UnitEnum|null $navigationGroup = 'Entraînement';
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 3;
|
||||||
|
|
||||||
|
protected static ?string $modelLabel = 'séance';
|
||||||
|
|
||||||
|
protected static ?string $pluralModelLabel = 'séances';
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'title';
|
||||||
|
|
||||||
|
public static function infolist(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return WorkoutSessionForm::configure($schema);
|
return WorkoutSessionInfolist::configure($schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
@@ -30,19 +44,28 @@ class WorkoutSessionResource extends Resource
|
|||||||
return WorkoutSessionsTable::configure($table);
|
return WorkoutSessionsTable::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 ['title', 'user.name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPages(): array
|
public static function getPages(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'index' => ListWorkoutSessions::route('/'),
|
'index' => ListWorkoutSessions::route('/'),
|
||||||
'create' => CreateWorkoutSession::route('/create'),
|
|
||||||
'edit' => EditWorkoutSession::route('/{record}/edit'),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Widgets;
|
||||||
|
|
||||||
|
use Filament\Widgets\ChartWidget;
|
||||||
|
use Functional\Exercises\Models\Exercise;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Répartition du catalogue d'exercices par partie du corps ciblée (doughnut).
|
||||||
|
*/
|
||||||
|
class ExercisesByBodyPartChart extends ChartWidget
|
||||||
|
{
|
||||||
|
protected static ?int $sort = 4;
|
||||||
|
|
||||||
|
protected int|string|array $columnSpan = 1;
|
||||||
|
|
||||||
|
/** Palette "flamme" dégradée pour distinguer les parts sans dépendre de couleurs génériques. */
|
||||||
|
private const PALETTE = [
|
||||||
|
'#f59e0b', '#fb923c', '#f97316', '#ea580c', '#c2410c',
|
||||||
|
'#fbbf24', '#fcd34d', '#fde68a', '#d97706', '#b45309',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getHeading(): string
|
||||||
|
{
|
||||||
|
return 'Exercices par partie du corps';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getData(): array
|
||||||
|
{
|
||||||
|
$countsByBodyPart = Exercise::query()
|
||||||
|
->whereNotNull('body_part')
|
||||||
|
->selectRaw('body_part, COUNT(*) as total')
|
||||||
|
->groupBy('body_part')
|
||||||
|
->orderByDesc('total')
|
||||||
|
->pluck('total', 'body_part');
|
||||||
|
|
||||||
|
return [
|
||||||
|
'datasets' => [
|
||||||
|
[
|
||||||
|
'data' => $countsByBodyPart->values()->all(),
|
||||||
|
'backgroundColor' => self::PALETTE,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'labels' => $countsByBodyPart->keys()->all(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getType(): string
|
||||||
|
{
|
||||||
|
return 'doughnut';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,8 @@ use Illuminate\Support\Carbon;
|
|||||||
*/
|
*/
|
||||||
class StreakFitStatsOverview extends StatsOverviewWidget
|
class StreakFitStatsOverview extends StatsOverviewWidget
|
||||||
{
|
{
|
||||||
|
protected static ?int $sort = 1;
|
||||||
|
|
||||||
protected function getStats(): array
|
protected function getStats(): array
|
||||||
{
|
{
|
||||||
$sessionsThisWeek = WorkoutSession::query()
|
$sessionsThisWeek = WorkoutSession::query()
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Widgets;
|
||||||
|
|
||||||
|
use Filament\Widgets\ChartWidget;
|
||||||
|
use Functional\Tracking\Models\SetLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Top 8 des exercices les plus loggés (nombre de séries), tous utilisateurs confondus.
|
||||||
|
*/
|
||||||
|
class TopExercisesChart extends ChartWidget
|
||||||
|
{
|
||||||
|
protected static ?int $sort = 5;
|
||||||
|
|
||||||
|
protected int|string|array $columnSpan = 'full';
|
||||||
|
|
||||||
|
private const TOP_COUNT = 8;
|
||||||
|
|
||||||
|
public function getHeading(): string
|
||||||
|
{
|
||||||
|
return 'Top 8 des exercices les plus loggés';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getData(): array
|
||||||
|
{
|
||||||
|
$topExercises = SetLog::query()
|
||||||
|
->join('exercises', 'exercises.id', '=', 'set_logs.exercise_id')
|
||||||
|
->selectRaw('exercises.name as name, COUNT(*) as total')
|
||||||
|
->groupBy('exercises.id', 'exercises.name')
|
||||||
|
->orderByDesc('total')
|
||||||
|
->limit(self::TOP_COUNT)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'datasets' => [
|
||||||
|
[
|
||||||
|
'label' => 'Séries loguées',
|
||||||
|
'data' => $topExercises->pluck('total')->all(),
|
||||||
|
'backgroundColor' => '#f97316',
|
||||||
|
'borderRadius' => 4,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'labels' => $topExercises->pluck('name')->all(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getType(): string
|
||||||
|
{
|
||||||
|
return 'bar';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Widgets;
|
||||||
|
|
||||||
|
use Filament\Widgets\ChartWidget;
|
||||||
|
use Functional\Users\Models\User;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Croissance cumulée des utilisateurs inscrits (ligne).
|
||||||
|
*/
|
||||||
|
class UsersGrowthChart extends ChartWidget
|
||||||
|
{
|
||||||
|
protected static ?int $sort = 3;
|
||||||
|
|
||||||
|
protected int|string|array $columnSpan = 1;
|
||||||
|
|
||||||
|
public function getHeading(): string
|
||||||
|
{
|
||||||
|
return 'Croissance des utilisateurs';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getData(): array
|
||||||
|
{
|
||||||
|
$countsByDay = User::query()
|
||||||
|
->selectRaw('DATE(created_at) as day, COUNT(*) as total')
|
||||||
|
->groupBy('day')
|
||||||
|
->orderBy('day')
|
||||||
|
->pluck('total', 'day');
|
||||||
|
|
||||||
|
$labels = [];
|
||||||
|
$data = [];
|
||||||
|
$cumulative = 0;
|
||||||
|
|
||||||
|
foreach ($countsByDay as $day => $total) {
|
||||||
|
$cumulative += (int) $total;
|
||||||
|
$labels[] = Carbon::parse($day)->format('d/m/Y');
|
||||||
|
$data[] = $cumulative;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'datasets' => [
|
||||||
|
[
|
||||||
|
'label' => 'Utilisateurs inscrits (cumulé)',
|
||||||
|
'data' => $data,
|
||||||
|
'borderColor' => '#f59e0b',
|
||||||
|
'backgroundColor' => 'rgba(245, 158, 11, 0.15)',
|
||||||
|
'fill' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'labels' => $labels,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getType(): string
|
||||||
|
{
|
||||||
|
return 'line';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Widgets;
|
||||||
|
|
||||||
|
use Filament\Widgets\ChartWidget;
|
||||||
|
use Functional\Tracking\Enums\WorkoutSessionStatus;
|
||||||
|
use Functional\Tracking\Models\WorkoutSession;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Séances complétées par jour sur les 30 derniers jours (barres).
|
||||||
|
* Permet de repérer les pics/creux d'activité de la communauté.
|
||||||
|
*/
|
||||||
|
class WorkoutSessionsPerDayChart extends ChartWidget
|
||||||
|
{
|
||||||
|
protected static ?int $sort = 2;
|
||||||
|
|
||||||
|
protected int|string|array $columnSpan = 'full';
|
||||||
|
|
||||||
|
public function getHeading(): string
|
||||||
|
{
|
||||||
|
return 'Séances complétées (30 derniers jours)';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getData(): array
|
||||||
|
{
|
||||||
|
$start = Carbon::now()->subDays(29)->startOfDay();
|
||||||
|
|
||||||
|
// Nombre de séances complétées par jour, sur la fenêtre glissante de 30 jours.
|
||||||
|
$countsByDay = WorkoutSession::query()
|
||||||
|
->where('status', WorkoutSessionStatus::Completed)
|
||||||
|
->where('started_at', '>=', $start)
|
||||||
|
->selectRaw('DATE(started_at) as day, COUNT(*) as total')
|
||||||
|
->groupBy('day')
|
||||||
|
->pluck('total', 'day');
|
||||||
|
|
||||||
|
$labels = [];
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
// On matérialise chaque jour (même sans séance) pour un axe continu.
|
||||||
|
for ($offset = 0; $offset < 30; $offset++) {
|
||||||
|
$date = $start->copy()->addDays($offset);
|
||||||
|
$key = $date->format('Y-m-d');
|
||||||
|
|
||||||
|
$labels[] = $date->format('d/m');
|
||||||
|
$data[] = (int) ($countsByDay[$key] ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'datasets' => [
|
||||||
|
[
|
||||||
|
'label' => 'Séances complétées',
|
||||||
|
'data' => $data,
|
||||||
|
'backgroundColor' => '#f59e0b',
|
||||||
|
'borderRadius' => 4,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'labels' => $labels,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getType(): string
|
||||||
|
{
|
||||||
|
return 'bar';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Providers\Filament;
|
namespace App\Providers\Filament;
|
||||||
|
|
||||||
|
use App\Filament\Widgets\ExercisesByBodyPartChart;
|
||||||
use App\Filament\Widgets\StreakFitStatsOverview;
|
use App\Filament\Widgets\StreakFitStatsOverview;
|
||||||
|
use App\Filament\Widgets\TopExercisesChart;
|
||||||
|
use App\Filament\Widgets\UsersGrowthChart;
|
||||||
|
use App\Filament\Widgets\WorkoutSessionsPerDayChart;
|
||||||
|
use BezhanSalleh\FilamentShield\FilamentShieldPlugin;
|
||||||
use Filament\Http\Middleware\Authenticate;
|
use Filament\Http\Middleware\Authenticate;
|
||||||
use Filament\Http\Middleware\AuthenticateSession;
|
use Filament\Http\Middleware\AuthenticateSession;
|
||||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||||
@@ -21,10 +26,11 @@ use Illuminate\View\Middleware\ShareErrorsFromSession;
|
|||||||
/**
|
/**
|
||||||
* Back-office StreakFit (Filament).
|
* Back-office StreakFit (Filament).
|
||||||
*
|
*
|
||||||
* Thème "flamme" : accent orange/amber sur base claire + dark mode.
|
* Thème "flamme" : accent amber/orange sur base zinc + dark mode.
|
||||||
|
* Navigation regroupée par domaine métier (Catalogue, Communauté, Entraînement,
|
||||||
|
* Gamification, Système), dashboard enrichi de charts (cf. app/Filament/Widgets).
|
||||||
* Auth via le guard 'web' standard (compatible avec le flow Sanctum SPA du front) ;
|
* Auth via le guard 'web' standard (compatible avec le flow Sanctum SPA du front) ;
|
||||||
* l'accès effectif au panel sera verrouillé quand le model User implémentera
|
* l'accès effectif au panel est verrouillé par User::canAccessPanel() (hasRole('admin')).
|
||||||
* Filament\Models\Contracts\FilamentUser::canAccessPanel().
|
|
||||||
*/
|
*/
|
||||||
class AdminPanelProvider extends PanelProvider
|
class AdminPanelProvider extends PanelProvider
|
||||||
{
|
{
|
||||||
@@ -35,17 +41,30 @@ class AdminPanelProvider extends PanelProvider
|
|||||||
->id('admin')
|
->id('admin')
|
||||||
->path('admin')
|
->path('admin')
|
||||||
->brandName('StreakFit 🔥')
|
->brandName('StreakFit 🔥')
|
||||||
|
->favicon(asset('favicon.ico'))
|
||||||
->login()
|
->login()
|
||||||
// Guard web standard : n'interfère pas avec l'auth Sanctum du front.
|
// Guard web standard : n'interfère pas avec l'auth Sanctum du front.
|
||||||
->authGuard('web')
|
->authGuard('web')
|
||||||
// Accent "flamme" : orange en primaire, amber en secondaire (warning).
|
// Accent "flamme" : amber en primaire, orange en secondaire (warning), gris zinc neutre.
|
||||||
->colors([
|
->colors([
|
||||||
'primary' => Color::Orange,
|
'primary' => Color::Amber,
|
||||||
'warning' => Color::Amber,
|
'warning' => Color::Orange,
|
||||||
'danger' => Color::Red,
|
'danger' => Color::Red,
|
||||||
'success' => Color::Emerald,
|
'success' => Color::Emerald,
|
||||||
|
'gray' => Color::Zinc,
|
||||||
|
])
|
||||||
|
// Dark mode disponible via le sélecteur clair/sombre (activé explicitement, non forcé).
|
||||||
|
->darkMode(condition: true, isForced: false)
|
||||||
|
// Barre latérale repliable sur desktop (gain de place sur les grandes tables).
|
||||||
|
->sidebarCollapsibleOnDesktop()
|
||||||
|
// Ordre d'affichage des groupes de navigation dans la sidebar.
|
||||||
|
->navigationGroups([
|
||||||
|
'Catalogue',
|
||||||
|
'Communauté',
|
||||||
|
'Entraînement',
|
||||||
|
'Gamification',
|
||||||
|
'Système',
|
||||||
])
|
])
|
||||||
// Dark mode disponible via le sélecteur clair/sombre (activé par défaut).
|
|
||||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
|
->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
|
||||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages')
|
->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages')
|
||||||
->pages([
|
->pages([
|
||||||
@@ -54,6 +73,17 @@ class AdminPanelProvider extends PanelProvider
|
|||||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\Filament\Widgets')
|
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\Filament\Widgets')
|
||||||
->widgets([
|
->widgets([
|
||||||
StreakFitStatsOverview::class,
|
StreakFitStatsOverview::class,
|
||||||
|
WorkoutSessionsPerDayChart::class,
|
||||||
|
UsersGrowthChart::class,
|
||||||
|
ExercisesByBodyPartChart::class,
|
||||||
|
TopExercisesChart::class,
|
||||||
|
])
|
||||||
|
// Gestion des rôles/permissions (Spatie) via Filament Shield — fournit sa propre
|
||||||
|
// RoleResource, rangée dans "Communauté" à côté de l'utilisateur.
|
||||||
|
->plugins([
|
||||||
|
FilamentShieldPlugin::make()
|
||||||
|
->navigationGroup('Communauté')
|
||||||
|
->navigationSort(2),
|
||||||
])
|
])
|
||||||
->middleware([
|
->middleware([
|
||||||
EncryptCookies::class,
|
EncryptCookies::class,
|
||||||
|
|||||||
+2
-1
@@ -7,6 +7,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.3",
|
"php": "^8.3",
|
||||||
|
"bezhansalleh/filament-shield": "^4.2",
|
||||||
"filament/filament": "^5.0",
|
"filament/filament": "^5.0",
|
||||||
"functional/exercises": "*",
|
"functional/exercises": "*",
|
||||||
"functional/programs": "*",
|
"functional/programs": "*",
|
||||||
@@ -22,7 +23,7 @@
|
|||||||
"league/flysystem-aws-s3-v3": "^3.0",
|
"league/flysystem-aws-s3-v3": "^3.0",
|
||||||
"lomkit/laravel-access-control": "^0.5.0",
|
"lomkit/laravel-access-control": "^0.5.0",
|
||||||
"lomkit/laravel-rest-api": "^2.22",
|
"lomkit/laravel-rest-api": "^2.22",
|
||||||
"spatie/laravel-permission": "^8.3",
|
"spatie/laravel-permission": "^7.0",
|
||||||
"technical/integrations": "*",
|
"technical/integrations": "*",
|
||||||
"technical/osdd": "*",
|
"technical/osdd": "*",
|
||||||
"xefi/laravel-osdd": "^2.0"
|
"xefi/laravel-osdd": "^2.0"
|
||||||
|
|||||||
Generated
+182
-10
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "1fd71e714394b125185f4b12ac7e5165",
|
"content-hash": "154031ad784b188e7ceda6ba0ded7192",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "anourvalar/eloquent-serialize",
|
"name": "anourvalar/eloquent-serialize",
|
||||||
@@ -222,6 +222,179 @@
|
|||||||
},
|
},
|
||||||
"time": "2026-07-17T18:11:29+00:00"
|
"time": "2026-07-17T18:11:29+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "bezhansalleh/filament-plugin-essentials",
|
||||||
|
"version": "1.2.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/bezhanSalleh/filament-plugin-essentials.git",
|
||||||
|
"reference": "de3a8a07edcf1bc9fe829480ae09aa00265e7f03"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/bezhanSalleh/filament-plugin-essentials/zipball/de3a8a07edcf1bc9fe829480ae09aa00265e7f03",
|
||||||
|
"reference": "de3a8a07edcf1bc9fe829480ae09aa00265e7f03",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"filament/filament": "^4.0|^5.0",
|
||||||
|
"illuminate/contracts": "^11.28|^12.0|^13.0",
|
||||||
|
"php": "^8.2|^8.3",
|
||||||
|
"spatie/laravel-package-tools": "^1.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"larastan/larastan": "^3.0",
|
||||||
|
"laravel/pint": "^1.14",
|
||||||
|
"nunomaduro/collision": "^7.10.0|^8.1.1",
|
||||||
|
"orchestra/testbench": "^9.0.0|^10.0.0|^11.0.0",
|
||||||
|
"pestphp/pest": "^3.0|^4.0",
|
||||||
|
"pestphp/pest-plugin-arch": "^3.0|^4.0",
|
||||||
|
"pestphp/pest-plugin-laravel": "^3.0|^4.0",
|
||||||
|
"pestphp/pest-plugin-type-coverage": "^3.5|^4.0",
|
||||||
|
"phpstan/extension-installer": "^1.3|^2.0",
|
||||||
|
"phpstan/phpstan-deprecation-rules": "^1.1|^2.0",
|
||||||
|
"phpstan/phpstan-phpunit": "^1.3|^2.0",
|
||||||
|
"rector/rector": "^2.1",
|
||||||
|
"spatie/laravel-ray": "^1.40"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"BezhanSalleh\\PluginEssentials\\PluginEssentialsServiceProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"BezhanSalleh\\PluginEssentials\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Bezhan Salleh",
|
||||||
|
"email": "bezhan_salleh@yahoo.com",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A collection of essential traits that streamline Filament plugin development by taking care of the boilerplate, so you can focus on shipping real features faster",
|
||||||
|
"homepage": "https://github.com/bezhansalleh/filament-plugin-essentials",
|
||||||
|
"keywords": [
|
||||||
|
"Bezhan Salleh",
|
||||||
|
"filament-plugin-essentials",
|
||||||
|
"laravel"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/bezhanSalleh/filament-plugin-essentials/issues",
|
||||||
|
"source": "https://github.com/bezhanSalleh/filament-plugin-essentials/tree/1.2.1"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/bezhanSalleh",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2026-03-22T08:15:32+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bezhansalleh/filament-shield",
|
||||||
|
"version": "4.2.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/bezhanSalleh/filament-shield.git",
|
||||||
|
"reference": "a48ea9ca115c644ce40380b853142afcd65e38d1"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/bezhanSalleh/filament-shield/zipball/a48ea9ca115c644ce40380b853142afcd65e38d1",
|
||||||
|
"reference": "a48ea9ca115c644ce40380b853142afcd65e38d1",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"bezhansalleh/filament-plugin-essentials": "^1.0",
|
||||||
|
"filament/filament": "^4.0|^5.0",
|
||||||
|
"illuminate/contracts": "^11.28|^12.0|^13.0",
|
||||||
|
"illuminate/support": "^11.28|^12.0|^13.0",
|
||||||
|
"php": "^8.2|^8.3",
|
||||||
|
"spatie/laravel-package-tools": "^1.0",
|
||||||
|
"spatie/laravel-permission": "^6.0|^7.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"larastan/larastan": "^3.0",
|
||||||
|
"laravel/pint": "^1.26",
|
||||||
|
"nunomaduro/collision": "^8.8",
|
||||||
|
"orchestra/testbench": "^9.0|^10.0|^11.0",
|
||||||
|
"pestphp/pest": "^3.8|^4.0",
|
||||||
|
"pestphp/pest-plugin-laravel": "^3.2|^4.0",
|
||||||
|
"pestphp/pest-plugin-livewire": "^3.0|^4.0",
|
||||||
|
"pestphp/pest-plugin-type-coverage": "^3.6|^4.0",
|
||||||
|
"phpstan/extension-installer": "^1.4",
|
||||||
|
"phpstan/phpstan": "^2.1",
|
||||||
|
"phpstan/phpstan-deprecation-rules": "^2.0",
|
||||||
|
"phpstan/phpstan-phpunit": "^2.0",
|
||||||
|
"phpunit/phpunit": "^11.0|^12.0",
|
||||||
|
"rector/jack": "^0.4.0",
|
||||||
|
"rector/rector": "^2.2",
|
||||||
|
"spatie/laravel-ray": "^1.43"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"aliases": {
|
||||||
|
"FilamentShield": "BezhanSalleh\\FilamentShield\\Facades\\FilamentShield"
|
||||||
|
},
|
||||||
|
"providers": [
|
||||||
|
"BezhanSalleh\\FilamentShield\\FilamentShieldServiceProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"BezhanSalleh\\FilamentShield\\": "src",
|
||||||
|
"BezhanSalleh\\FilamentShield\\Database\\Factories\\": "database/factories"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Bezhan Salleh",
|
||||||
|
"email": "bezhan_salleh@yahoo.com",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Filament support for `spatie/laravel-permission`.",
|
||||||
|
"homepage": "https://github.com/bezhansalleh/filament-shield",
|
||||||
|
"keywords": [
|
||||||
|
"acl",
|
||||||
|
"bezhanSalleh",
|
||||||
|
"filament",
|
||||||
|
"filament-shield",
|
||||||
|
"laravel",
|
||||||
|
"permission",
|
||||||
|
"permissions",
|
||||||
|
"rbac",
|
||||||
|
"roles",
|
||||||
|
"security"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/bezhanSalleh/filament-shield/issues",
|
||||||
|
"source": "https://github.com/bezhanSalleh/filament-shield/tree/4.2.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/bezhanSalleh",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2026-03-22T08:31:44+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "blade-ui-kit/blade-heroicons",
|
"name": "blade-ui-kit/blade-heroicons",
|
||||||
"version": "2.7.0",
|
"version": "2.7.0",
|
||||||
@@ -6200,16 +6373,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "spatie/laravel-permission",
|
"name": "spatie/laravel-permission",
|
||||||
"version": "8.3.0",
|
"version": "7.4.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/spatie/laravel-permission.git",
|
"url": "https://github.com/spatie/laravel-permission.git",
|
||||||
"reference": "60e8ed5b2fbf043c2264433fc2680c76b8b66aa6"
|
"reference": "15a9daf02ba02d3ae77aaa6da582708231ef999b"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/spatie/laravel-permission/zipball/60e8ed5b2fbf043c2264433fc2680c76b8b66aa6",
|
"url": "https://api.github.com/repos/spatie/laravel-permission/zipball/15a9daf02ba02d3ae77aaa6da582708231ef999b",
|
||||||
"reference": "60e8ed5b2fbf043c2264433fc2680c76b8b66aa6",
|
"reference": "15a9daf02ba02d3ae77aaa6da582708231ef999b",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -6222,7 +6395,6 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"larastan/larastan": "^3.9",
|
"larastan/larastan": "^3.9",
|
||||||
"laravel/octane": "^2.0",
|
|
||||||
"laravel/passport": "^13.0",
|
"laravel/passport": "^13.0",
|
||||||
"laravel/pint": "^1.0",
|
"laravel/pint": "^1.0",
|
||||||
"orchestra/testbench": "^10.0|^11.0",
|
"orchestra/testbench": "^10.0|^11.0",
|
||||||
@@ -6238,8 +6410,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "8.x-dev",
|
"dev-main": "7.x-dev",
|
||||||
"dev-master": "8.x-dev"
|
"dev-master": "7.x-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -6276,7 +6448,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/spatie/laravel-permission/issues",
|
"issues": "https://github.com/spatie/laravel-permission/issues",
|
||||||
"source": "https://github.com/spatie/laravel-permission/tree/8.3.0"
|
"source": "https://github.com/spatie/laravel-permission/tree/7.4.2"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -6284,7 +6456,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2026-07-03T15:36:01+00:00"
|
"time": "2026-05-30T19:21:26+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "spatie/shiki-php",
|
"name": "spatie/shiki-php",
|
||||||
|
|||||||
@@ -0,0 +1,267 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
use BezhanSalleh\FilamentShield\Resources\Roles\RoleResource;
|
||||||
|
use Filament\Pages\Dashboard;
|
||||||
|
use Filament\Widgets\AccountWidget;
|
||||||
|
use Filament\Widgets\FilamentInfoWidget;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Shield Resource
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure the built-in role management resource. You can
|
||||||
|
| customize the URL, choose whether to show model paths, group it under
|
||||||
|
| a cluster, and decide which permission tabs to display.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'shield_resource' => [
|
||||||
|
'slug' => 'shield/roles',
|
||||||
|
'show_model_path' => true,
|
||||||
|
'cluster' => null,
|
||||||
|
'tabs' => [
|
||||||
|
'pages' => true,
|
||||||
|
'widgets' => true,
|
||||||
|
'resources' => true,
|
||||||
|
'custom_permissions' => false,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Multi-Tenancy
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When your application supports teams, Shield will automatically detect
|
||||||
|
| and configure the tenant model during setup. This enables tenant-scoped
|
||||||
|
| roles and permissions throughout your application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'tenant_model' => null,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| User Model
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value contains the class name of your user model. This model will
|
||||||
|
| be used for role assignments and must implement the HasRoles trait
|
||||||
|
| provided by the Spatie\Permission package.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'auth_provider_model' => 'App\\Models\\User',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Super Admin
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may define a super admin that has unrestricted access to your
|
||||||
|
| application. You can choose to implement this via Laravel's gate system
|
||||||
|
| or as a traditional role with all permissions explicitly assigned.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'super_admin' => [
|
||||||
|
'enabled' => true,
|
||||||
|
'name' => 'super_admin',
|
||||||
|
'define_via_gate' => false,
|
||||||
|
'intercept_gate' => 'before',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Panel User
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When enabled, Shield will create a basic panel user role that can be
|
||||||
|
| assigned to users who should have access to your Filament panels but
|
||||||
|
| don't need any specific permissions beyond basic authentication.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'panel_user' => [
|
||||||
|
'enabled' => true,
|
||||||
|
'name' => 'panel_user',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Permission Builder
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| You can customize how permission keys are generated to match your
|
||||||
|
| preferred naming convention and organizational standards. Shield uses
|
||||||
|
| these settings when creating permission names from your resources.
|
||||||
|
|
|
||||||
|
| Supported formats: snake, kebab, pascal, camel, upper_snake, lower_snake
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'permissions' => [
|
||||||
|
'separator' => ':',
|
||||||
|
'case' => 'pascal',
|
||||||
|
'generate' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Policies
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Shield can automatically generate Laravel policies for your resources.
|
||||||
|
| When merge is enabled, the methods below will be combined with any
|
||||||
|
| resource-specific methods you define in the resources section.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'policies' => [
|
||||||
|
'path' => app_path('Policies'),
|
||||||
|
'merge' => true,
|
||||||
|
'generate' => true,
|
||||||
|
'methods' => [
|
||||||
|
'viewAny', 'view', 'create', 'update', 'delete', 'deleteAny', 'restore',
|
||||||
|
'forceDelete', 'forceDeleteAny', 'restoreAny', 'replicate', 'reorder',
|
||||||
|
],
|
||||||
|
'single_parameter_methods' => [
|
||||||
|
'viewAny',
|
||||||
|
'create',
|
||||||
|
'deleteAny',
|
||||||
|
'forceDeleteAny',
|
||||||
|
'restoreAny',
|
||||||
|
'reorder',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Localization
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Shield supports multiple languages out of the box. When enabled, you
|
||||||
|
| can provide translated labels for permissions to create a more
|
||||||
|
| localized experience for your international users.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'localization' => [
|
||||||
|
'enabled' => false,
|
||||||
|
'key' => 'filament-shield::filament-shield.resource_permission_prefixes_labels',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Resources
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you can fine-tune permissions for specific Filament resources.
|
||||||
|
| Use the 'manage' array to override the default policy methods for
|
||||||
|
| individual resources, giving you granular control over permissions.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'resources' => [
|
||||||
|
'subject' => 'model',
|
||||||
|
'manage' => [
|
||||||
|
RoleResource::class => [
|
||||||
|
'viewAny',
|
||||||
|
'view',
|
||||||
|
'create',
|
||||||
|
'update',
|
||||||
|
'delete',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'exclude' => [
|
||||||
|
//
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Pages
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Most Filament pages only require view permissions. Pages listed in the
|
||||||
|
| exclude array will be skipped during permission generation and won't
|
||||||
|
| appear in your role management interface.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'pages' => [
|
||||||
|
'subject' => 'class',
|
||||||
|
'prefix' => 'view',
|
||||||
|
'exclude' => [
|
||||||
|
Dashboard::class,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Widgets
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Like pages, widgets typically only need view permissions. Add widgets
|
||||||
|
| to the exclude array if you don't want them to appear in your role
|
||||||
|
| management interface.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'widgets' => [
|
||||||
|
'subject' => 'class',
|
||||||
|
'prefix' => 'view',
|
||||||
|
'exclude' => [
|
||||||
|
AccountWidget::class,
|
||||||
|
FilamentInfoWidget::class,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Custom Permissions
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Sometimes you need permissions that don't map to resources, pages, or
|
||||||
|
| widgets. Define any custom permissions here and they'll be available
|
||||||
|
| when editing roles in your application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'custom_permissions' => [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Entity Discovery
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By default, Shield only looks for entities in your default Filament
|
||||||
|
| panel. Enable these options if you're using multiple panels and want
|
||||||
|
| Shield to discover entities across all of them.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'discovery' => [
|
||||||
|
'discover_all_resources' => false,
|
||||||
|
'discover_all_widgets' => false,
|
||||||
|
'discover_all_pages' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Role Policy
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Shield can automatically register a policy for role management itself.
|
||||||
|
| This lets you control who can manage roles using Laravel's built-in
|
||||||
|
| authorization system. Requires a RolePolicy class in your app.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'register_role_policy' => true,
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1,219 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Spatie\Permission\DefaultTeamResolver;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
'models' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasPermissions" trait from this package, we need to know which
|
||||||
|
* Eloquent model should be used to retrieve your permissions. Of course, it
|
||||||
|
* is often just the "Permission" model but you may use whatever you like.
|
||||||
|
*
|
||||||
|
* The model you want to use as a Permission model needs to implement the
|
||||||
|
* `Spatie\Permission\Contracts\Permission` contract.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'permission' => Permission::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasRoles" trait from this package, we need to know which
|
||||||
|
* Eloquent model should be used to retrieve your roles. Of course, it
|
||||||
|
* is often just the "Role" model but you may use whatever you like.
|
||||||
|
*
|
||||||
|
* The model you want to use as a Role model needs to implement the
|
||||||
|
* `Spatie\Permission\Contracts\Role` contract.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'role' => Role::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "Teams" feature from this package, we need to know which
|
||||||
|
* Eloquent model should be used to retrieve your teams. Of course, it
|
||||||
|
* is often just the "Team" model but you may use whatever you like.
|
||||||
|
*/
|
||||||
|
'team' => null,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasModels" trait and passing raw IDs to syncModels,
|
||||||
|
* attachModels, or detachModels, this model class will be used to
|
||||||
|
* resolve those IDs. If null, defaults to the guard's model.
|
||||||
|
*/
|
||||||
|
'default_model' => null,
|
||||||
|
],
|
||||||
|
|
||||||
|
'table_names' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasRoles" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your roles. We have chosen a basic
|
||||||
|
* default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'roles' => 'roles',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasPermissions" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your permissions. We have chosen a basic
|
||||||
|
* default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'permissions' => 'permissions',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasPermissions" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your models permissions. We have chosen a
|
||||||
|
* basic default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'model_has_permissions' => 'model_has_permissions',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasRoles" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your models roles. We have chosen a
|
||||||
|
* basic default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'model_has_roles' => 'model_has_roles',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasRoles" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your roles permissions. We have chosen a
|
||||||
|
* basic default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'role_has_permissions' => 'role_has_permissions',
|
||||||
|
],
|
||||||
|
|
||||||
|
'column_names' => [
|
||||||
|
/*
|
||||||
|
* Change this if you want to name the related pivots other than defaults
|
||||||
|
*/
|
||||||
|
'role_pivot_key' => null, // default 'role_id',
|
||||||
|
'permission_pivot_key' => null, // default 'permission_id',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Change this if you want to name the related model primary key other than
|
||||||
|
* `model_id`.
|
||||||
|
*
|
||||||
|
* For example, this would be nice if your primary keys are all UUIDs. In
|
||||||
|
* that case, name this `model_uuid`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'model_morph_key' => 'model_id',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Change this if you want to use the teams feature and your related model's
|
||||||
|
* foreign key is other than `team_id`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'team_foreign_key' => 'team_id',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When set to true, the method for checking permissions will be registered on the gate.
|
||||||
|
* Set this to false if you want to implement custom logic for checking permissions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'register_permission_check_method' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When set to true, Laravel\Octane\Events\OperationTerminated event listener will be registered
|
||||||
|
* this will refresh permissions on every TickTerminated, TaskTerminated and RequestTerminated
|
||||||
|
* NOTE: This should not be needed in most cases, but an Octane/Vapor combination benefited from it.
|
||||||
|
*/
|
||||||
|
'register_octane_reset_listener' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Events will fire when a role or permission is assigned/unassigned:
|
||||||
|
* \Spatie\Permission\Events\RoleAttachedEvent
|
||||||
|
* \Spatie\Permission\Events\RoleDetachedEvent
|
||||||
|
* \Spatie\Permission\Events\PermissionAttachedEvent
|
||||||
|
* \Spatie\Permission\Events\PermissionDetachedEvent
|
||||||
|
*
|
||||||
|
* To enable, set to true, and then create listeners to watch these events.
|
||||||
|
*/
|
||||||
|
'events_enabled' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Teams Feature.
|
||||||
|
* When set to true the package implements teams using the 'team_foreign_key'.
|
||||||
|
* If you want the migrations to register the 'team_foreign_key', you must
|
||||||
|
* set this to true before doing the migration.
|
||||||
|
* If you already did the migration then you must make a new migration to also
|
||||||
|
* add 'team_foreign_key' to 'roles', 'model_has_roles', and 'model_has_permissions'
|
||||||
|
* (view the latest version of this package's migration file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
'teams' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The class to use to resolve the permissions team id
|
||||||
|
*/
|
||||||
|
'team_resolver' => DefaultTeamResolver::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Passport Client Credentials Grant
|
||||||
|
* When set to true the package will use Passports Client to check permissions
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use_passport_client_credentials' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When set to true, the required permission names are added to exception messages.
|
||||||
|
* This could be considered an information leak in some contexts, so the default
|
||||||
|
* setting is false here for optimum safety.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'display_permission_in_exception' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When set to true, the required role names are added to exception messages.
|
||||||
|
* This could be considered an information leak in some contexts, so the default
|
||||||
|
* setting is false here for optimum safety.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'display_role_in_exception' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* By default wildcard permission lookups are disabled.
|
||||||
|
* See documentation to understand supported syntax.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'enable_wildcard_permission' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The class to use for interpreting wildcard permissions.
|
||||||
|
* If you need to modify delimiters, override the class and specify its name here.
|
||||||
|
*/
|
||||||
|
// 'wildcard_permission' => Spatie\Permission\WildcardPermission::class,
|
||||||
|
|
||||||
|
/* Cache-specific settings */
|
||||||
|
|
||||||
|
'cache' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
* By default all permissions are cached for 24 hours to speed up performance.
|
||||||
|
* When permissions or roles are updated the cache is flushed automatically.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'expiration_time' => DateInterval::createFromDateString('24 hours'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The cache key used to store all permissions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'key' => 'spatie.permission.cache',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* You may optionally indicate a specific cache driver to use for permission and
|
||||||
|
* role caching using any of the `store` drivers listed in the cache.php config
|
||||||
|
* file. Using 'default' here means to use the `default` set in cache.php.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'store' => 'default',
|
||||||
|
],
|
||||||
|
];
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$teams = config('permission.teams');
|
||||||
|
$tableNames = config('permission.table_names');
|
||||||
|
$columnNames = config('permission.column_names');
|
||||||
|
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
|
||||||
|
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
|
||||||
|
|
||||||
|
throw_if(empty($tableNames), 'Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||||
|
throw_if($teams && empty($columnNames['team_foreign_key'] ?? null), 'Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
|
||||||
|
*/
|
||||||
|
Schema::create($tableNames['permissions'], static function (Blueprint $table) {
|
||||||
|
$table->id(); // permission id
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('guard_name');
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->unique(['name', 'guard_name']);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
|
||||||
|
*/
|
||||||
|
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
|
||||||
|
$table->id(); // role id
|
||||||
|
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||||
|
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||||
|
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||||
|
}
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('guard_name');
|
||||||
|
$table->timestamps();
|
||||||
|
if ($teams || config('permission.testing')) {
|
||||||
|
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||||
|
} else {
|
||||||
|
$table->unique(['name', 'guard_name']);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
|
||||||
|
$table->unsignedBigInteger($pivotPermission);
|
||||||
|
|
||||||
|
$table->string('model_type');
|
||||||
|
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||||
|
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||||
|
|
||||||
|
$table->foreign($pivotPermission)
|
||||||
|
->references('id') // permission id
|
||||||
|
->on($tableNames['permissions'])
|
||||||
|
->cascadeOnDelete();
|
||||||
|
if ($teams) {
|
||||||
|
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||||
|
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||||
|
|
||||||
|
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||||
|
'model_has_permissions_permission_model_type_primary');
|
||||||
|
} else {
|
||||||
|
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||||
|
'model_has_permissions_permission_model_type_primary');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
|
||||||
|
$table->unsignedBigInteger($pivotRole);
|
||||||
|
|
||||||
|
$table->string('model_type');
|
||||||
|
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||||
|
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||||
|
|
||||||
|
$table->foreign($pivotRole)
|
||||||
|
->references('id') // role id
|
||||||
|
->on($tableNames['roles'])
|
||||||
|
->cascadeOnDelete();
|
||||||
|
if ($teams) {
|
||||||
|
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||||
|
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||||
|
|
||||||
|
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||||
|
'model_has_roles_role_model_type_primary');
|
||||||
|
} else {
|
||||||
|
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||||
|
'model_has_roles_role_model_type_primary');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
|
||||||
|
$table->unsignedBigInteger($pivotPermission);
|
||||||
|
$table->unsignedBigInteger($pivotRole);
|
||||||
|
|
||||||
|
$table->foreign($pivotPermission)
|
||||||
|
->references('id') // permission id
|
||||||
|
->on($tableNames['permissions'])
|
||||||
|
->cascadeOnDelete();
|
||||||
|
|
||||||
|
$table->foreign($pivotRole)
|
||||||
|
->references('id') // role id
|
||||||
|
->on($tableNames['roles'])
|
||||||
|
->cascadeOnDelete();
|
||||||
|
|
||||||
|
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||||
|
});
|
||||||
|
|
||||||
|
app('cache')
|
||||||
|
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||||
|
->forget(config('permission.cache.key'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
$tableNames = config('permission.table_names');
|
||||||
|
|
||||||
|
throw_if(empty($tableNames), 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||||
|
|
||||||
|
Schema::dropIfExists($tableNames['role_has_permissions']);
|
||||||
|
Schema::dropIfExists($tableNames['model_has_roles']);
|
||||||
|
Schema::dropIfExists($tableNames['model_has_permissions']);
|
||||||
|
Schema::dropIfExists($tableNames['roles']);
|
||||||
|
Schema::dropIfExists($tableNames['permissions']);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -2,16 +2,21 @@
|
|||||||
|
|
||||||
namespace Functional\Routines\Http\Resources;
|
namespace Functional\Routines\Http\Resources;
|
||||||
|
|
||||||
|
use Functional\Exercises\Models\Exercise;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Une ligne du pivot routine_exercises, avec un sous-objet exercice minimal prêt-à-afficher.
|
* Une ligne du pivot routine_exercises, avec un sous-objet exercice minimal prêt-à-afficher
|
||||||
|
* (nom + muscle localisés selon la locale de la requête).
|
||||||
*/
|
*/
|
||||||
class RoutineExerciseResource extends JsonResource
|
class RoutineExerciseResource extends JsonResource
|
||||||
{
|
{
|
||||||
public function toArray(Request $request): array
|
public function toArray(Request $request): array
|
||||||
{
|
{
|
||||||
|
$locale = (string) ($request->query('locale') ?: 'fr');
|
||||||
|
$exercise = $this->exercise;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'exercise_id' => $this->exercise_id,
|
'exercise_id' => $this->exercise_id,
|
||||||
'position' => $this->position,
|
'position' => $this->position,
|
||||||
@@ -21,12 +26,12 @@ class RoutineExerciseResource extends JsonResource
|
|||||||
'tempo' => $this->tempo,
|
'tempo' => $this->tempo,
|
||||||
'target_weight' => $this->target_weight,
|
'target_weight' => $this->target_weight,
|
||||||
'notes' => $this->notes,
|
'notes' => $this->notes,
|
||||||
'exercise' => [
|
'exercise' => $exercise ? [
|
||||||
'id' => $this->exercise->id,
|
'id' => $exercise->id,
|
||||||
'name' => $this->exercise->name,
|
'name' => $exercise->localizedName($locale),
|
||||||
'image_url' => $this->exercise->image_url,
|
'image_url' => $exercise->image_url,
|
||||||
'target' => $this->exercise->target,
|
'target' => Exercise::localizeTerm($exercise->target, $locale),
|
||||||
],
|
] : null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
|||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Laravel\Sanctum\HasApiTokens;
|
use Laravel\Sanctum\HasApiTokens;
|
||||||
use NotificationChannels\WebPush\HasPushSubscriptions;
|
use NotificationChannels\WebPush\HasPushSubscriptions;
|
||||||
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property string $locale
|
* @property string $locale
|
||||||
@@ -28,12 +29,12 @@ use NotificationChannels\WebPush\HasPushSubscriptions;
|
|||||||
#[UseFactory(UserFactory::class)]
|
#[UseFactory(UserFactory::class)]
|
||||||
class User extends Authenticatable implements FilamentUser
|
class User extends Authenticatable implements FilamentUser
|
||||||
{
|
{
|
||||||
use HasApiTokens, HasFactory, HasPushSubscriptions, Notifiable;
|
use HasApiTokens, HasFactory, HasPushSubscriptions, HasRoles, Notifiable;
|
||||||
|
|
||||||
/** Accès au back-office Filament (à affiner : rôle admin plus tard). */
|
/** Accès au back-office Filament : réservé aux rôles "super_admin" ou "admin" (Filament Shield). */
|
||||||
public function canAccessPanel(Panel $panel): bool
|
public function canAccessPanel(Panel $panel): bool
|
||||||
{
|
{
|
||||||
return true;
|
return $this->hasAnyRole(['super_admin', 'admin']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user