feat: filament for users

This commit is contained in:
2026-05-21 14:53:44 +02:00
parent 646f5a1ea8
commit f24999d7fb
8 changed files with 365 additions and 37 deletions
+121 -15
View File
@@ -2,10 +2,19 @@
namespace App\Filament\Resources\Users\Schemas;
use App\Enums\PacePreference;
use App\Enums\PhysicalActivityLevel;
use App\Enums\UserSex;
use App\Enums\WeightGoal;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Illuminate\Validation\Rules\Password;
class UserForm
{
@@ -13,21 +22,118 @@ class UserForm
{
return $schema
->components([
TextInput::make('name')
->required(),
TextInput::make('email')
->label('Email address')
->email()
->required(),
FileUpload::make('avatar_url')
->label('Avatar')
->image()
->disk('public')
->directory('avatars'),
DateTimePicker::make('email_verified_at'),
TextInput::make('password')
->password()
->required(),
Section::make('Compte')
->columns(2)
->schema([
TextInput::make('name')
->label('Nom')
->required()
->maxLength(255),
TextInput::make('email')
->label('Adresse email')
->email()
->required()
->unique(ignoreRecord: true)
->maxLength(255),
FileUpload::make('avatar_url')
->label('Avatar')
->image()
->disk('public')
->directory('avatars')
->visibility('public')
->maxSize(2048),
TextInput::make('password')
->label('Mot de passe')
->password()
->revealable()
->rule(Password::default())
->required(fn (string $operation): bool => $operation === 'create')
->formatStateUsing(fn (): ?string => null)
->dehydrated(fn ($state): bool => filled($state))
->autocomplete('new-password'),
DateTimePicker::make('email_verified_at')
->label('Email vérifié le'),
DateTimePicker::make('account_verified_at')
->label('Compte vérifié le'),
]),
Section::make('Profil')
->columns(2)
->schema([
Textarea::make('bio')
->label('Bio')
->rows(4)
->columnSpanFull(),
TextInput::make('height')
->label('Taille')
->integer()
->minValue(0)
->maxValue(300)
->suffix('cm'),
DatePicker::make('date_of_birth')
->label('Date de naissance')
->minDate('1900-01-01')
->maxDate(now()->subDay()),
Select::make('sex')
->label('Sexe')
->options(UserSex::class)
->default(UserSex::UNKNOWN->value)
->required(),
]),
Section::make('Objectifs nutritionnels')
->columns(4)
->schema([
TextInput::make('daily_calorie_goal')
->label('Calories')
->integer()
->minValue(0)
->maxValue(100000)
->suffix('kcal')
->default(2000)
->required(),
TextInput::make('daily_protein_goal')
->label('Protéines')
->numeric()
->minValue(0)
->maxValue(10000)
->suffix('g')
->default(120)
->required(),
TextInput::make('daily_carbs_goal')
->label('Glucides')
->numeric()
->minValue(0)
->maxValue(10000)
->suffix('g')
->default(250)
->required(),
TextInput::make('daily_fats_goal')
->label('Lipides')
->numeric()
->minValue(0)
->maxValue(10000)
->suffix('g')
->default(70)
->required(),
]),
Section::make('Activité')
->columns(3)
->schema([
Select::make('physical_activity_level')
->label('Niveau dactivité')
->options(PhysicalActivityLevel::class)
->default(PhysicalActivityLevel::SEDENTARY->value)
->required(),
Select::make('weight_goal')
->label('Objectif de poids')
->options(WeightGoal::class)
->default(WeightGoal::LOSE_WEIGHT->value)
->required(),
Select::make('pace_preference')
->label('Rythme')
->options(PacePreference::class)
->default(PacePreference::SLOW->value)
->required(),
]),
]);
}
}