Save
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources;
|
||||
|
||||
use App\Filament\Admin\Resources\InformationResource\Pages;
|
||||
use App\Models\Information;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class InformationResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Information::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-information-circle';
|
||||
|
||||
protected static ?string $navigationLabel = 'Informations';
|
||||
|
||||
protected static ?string $modelLabel = 'Information';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('title')
|
||||
->label('Titre')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('category')
|
||||
->label('Catégorie')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->default('Général'),
|
||||
Forms\Components\RichEditor::make('content')
|
||||
->label('Contenu')
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
Forms\Components\FileUpload::make('image_url')
|
||||
->label('Image')
|
||||
->image()
|
||||
->directory('informations'),
|
||||
Forms\Components\Toggle::make('is_published')
|
||||
->label('Publié')
|
||||
->default(true)
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('title')
|
||||
->label('Titre')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('category')
|
||||
->label('Catégorie')
|
||||
->badge()
|
||||
->searchable(),
|
||||
Tables\Columns\IconColumn::make('is_published')
|
||||
->label('Publié')
|
||||
->boolean(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Créé le')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TernaryFilter::make('is_published')
|
||||
->label('Statut de publication')
|
||||
->boolean()
|
||||
->trueLabel('Publiés')
|
||||
->falseLabel('Brouillons')
|
||||
->native(false),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListInformation::route('/'),
|
||||
'create' => Pages\CreateInformation::route('/create'),
|
||||
'edit' => Pages\EditInformation::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\InformationResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\InformationResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateInformation extends CreateRecord
|
||||
{
|
||||
protected static string $resource = InformationResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\InformationResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\InformationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditInformation extends EditRecord
|
||||
{
|
||||
protected static string $resource = InformationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\InformationResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\InformationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListInformation extends ListRecords
|
||||
{
|
||||
protected static string $resource = InformationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources;
|
||||
|
||||
use App\Filament\Admin\Resources\RelaxationActivityResource\Pages;
|
||||
use App\Models\RelaxationActivity;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class RelaxationActivityResource extends Resource
|
||||
{
|
||||
protected static ?string $model = RelaxationActivity::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-sparkles';
|
||||
|
||||
protected static ?string $navigationLabel = 'Activités de détente';
|
||||
|
||||
protected static ?string $modelLabel = 'Activité de détente';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('title')
|
||||
->label('Titre')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\Select::make('type')
|
||||
->options([
|
||||
'video' => 'Vidéo',
|
||||
'audio' => 'Audio',
|
||||
'article' => 'Article',
|
||||
'exercice' => 'Exercice',
|
||||
])
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('duration')
|
||||
->label('Durée (min)')
|
||||
->numeric(),
|
||||
Forms\Components\TextInput::make('url')
|
||||
->label('Lien / URL')
|
||||
->url()
|
||||
->maxLength(255),
|
||||
Forms\Components\Textarea::make('description')
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('title')
|
||||
->label('Titre')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('type')
|
||||
->badge(),
|
||||
Tables\Columns\TextColumn::make('duration')
|
||||
->label('Durée')
|
||||
->suffix(' min'),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\SelectFilter::make('type')
|
||||
->options([
|
||||
'video' => 'Vidéo',
|
||||
'audio' => 'Audio',
|
||||
'article' => 'Article',
|
||||
'exercice' => 'Exercice',
|
||||
]),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListRelaxationActivities::route('/'),
|
||||
'create' => Pages\CreateRelaxationActivity::route('/create'),
|
||||
'edit' => Pages\EditRelaxationActivity::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\RelaxationActivityResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\RelaxationActivityResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateRelaxationActivity extends CreateRecord
|
||||
{
|
||||
protected static string $resource = RelaxationActivityResource::class;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\RelaxationActivityResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\RelaxationActivityResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditRelaxationActivity extends EditRecord
|
||||
{
|
||||
protected static string $resource = RelaxationActivityResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\RelaxationActivityResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\RelaxationActivityResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListRelaxationActivities extends ListRecords
|
||||
{
|
||||
protected static string $resource = RelaxationActivityResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources;
|
||||
|
||||
use App\Filament\Admin\Resources\StressEventResource\Pages;
|
||||
use App\Models\StressEvent;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class StressEventResource extends Resource
|
||||
{
|
||||
protected static ?string $model = StressEvent::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-bolt';
|
||||
|
||||
protected static ?string $navigationLabel = 'Événements de stress';
|
||||
|
||||
protected static ?string $modelLabel = 'Événement de stress';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Événements de stress';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('event_name')
|
||||
->label('Nom de l\'événement')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('points')
|
||||
->label('Points de stress')
|
||||
->required()
|
||||
->numeric()
|
||||
->minValue(0)
|
||||
->maxValue(100),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('event_name')
|
||||
->label('Événement')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('points')
|
||||
->label('Points')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Dernière modification')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListStressEvents::route('/'),
|
||||
'create' => Pages\CreateStressEvent::route('/create'),
|
||||
'edit' => Pages\EditStressEvent::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\StressEventResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\StressEventResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateStressEvent extends CreateRecord
|
||||
{
|
||||
protected static string $resource = StressEventResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\StressEventResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\StressEventResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditStressEvent extends EditRecord
|
||||
{
|
||||
protected static string $resource = StressEventResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\StressEventResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\StressEventResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListStressEvents extends ListRecords
|
||||
{
|
||||
protected static string $resource = StressEventResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources;
|
||||
|
||||
use App\Filament\Admin\Resources\UserResource\Pages;
|
||||
use App\Models\User;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class UserResource extends Resource
|
||||
{
|
||||
protected static ?string $model = User::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-users';
|
||||
|
||||
protected static ?string $navigationLabel = 'Utilisateurs';
|
||||
|
||||
protected static ?string $modelLabel = 'Utilisateur';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('email')
|
||||
->email()
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\Select::make('id_role')
|
||||
->relationship('role', 'libelle')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('password')
|
||||
->password()
|
||||
->dehydrated(fn ($state) => filled($state))
|
||||
->required(fn (string $context): bool => $context === 'create'),
|
||||
Forms\Components\Toggle::make('is_active')
|
||||
->label('Compte actif')
|
||||
->default(true)
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('email')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('role.libelle')
|
||||
->label('Rôle')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'Admin' => 'danger',
|
||||
'Utilisateur' => 'info',
|
||||
default => 'gray',
|
||||
}),
|
||||
Tables\Columns\ToggleColumn::make('is_active')
|
||||
->label('Actif'),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TernaryFilter::make('is_active')
|
||||
->label('Statut')
|
||||
->boolean()
|
||||
->trueLabel('Utilisateurs actifs')
|
||||
->falseLabel('Utilisateurs désactivés')
|
||||
->native(false),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListUsers::route('/'),
|
||||
'create' => Pages\CreateUser::route('/create'),
|
||||
'edit' => Pages\EditUser::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\UserResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\UserResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateUser extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\UserResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\UserResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditUser extends EditRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\UserResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\UserResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListUsers extends ListRecords
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user