feat: lang middleware and filament translations
This commit is contained in:
parent
f24999d7fb
commit
52a2104fdf
|
|
@ -13,9 +13,9 @@ enum PacePreference: string implements HasLabel
|
||||||
public function getLabel(): string
|
public function getLabel(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::SLOW => 'Lent',
|
self::SLOW => __('enums.pace_preference.slow'),
|
||||||
self::NORMAL => 'Normal',
|
self::NORMAL => __('enums.pace_preference.normal'),
|
||||||
self::FAST => 'Rapide',
|
self::FAST => __('enums.pace_preference.fast'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ enum PhysicalActivityLevel: string implements HasLabel
|
||||||
public function getLabel(): string
|
public function getLabel(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::SEDENTARY => 'Sédentaire',
|
self::SEDENTARY => __('enums.physical_activity_level.sedentary'),
|
||||||
self::LIGHTLY_ACTIVE => 'Légèrement actif',
|
self::LIGHTLY_ACTIVE => __('enums.physical_activity_level.lightly_active'),
|
||||||
self::MODERATELY_ACTIVE => 'Modérément actif',
|
self::MODERATELY_ACTIVE => __('enums.physical_activity_level.moderately_active'),
|
||||||
self::VERY_ACTIVE => 'Très actif',
|
self::VERY_ACTIVE => __('enums.physical_activity_level.very_active'),
|
||||||
self::ATHLETE => 'Athlète',
|
self::ATHLETE => __('enums.physical_activity_level.athlete'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@ enum UserSex: string implements HasLabel
|
||||||
public function getLabel(): string
|
public function getLabel(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::MAN => 'Homme',
|
self::MAN => __('enums.user_sex.man'),
|
||||||
self::WOMAN => 'Femme',
|
self::WOMAN => __('enums.user_sex.woman'),
|
||||||
self::OTHER => 'Autre',
|
self::OTHER => __('enums.user_sex.other'),
|
||||||
self::UNKNOWN => 'Non renseigné',
|
self::UNKNOWN => __('enums.user_sex.unknown'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ enum WeightGoal: string implements HasLabel
|
||||||
public function getLabel(): string
|
public function getLabel(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::LOSE_WEIGHT => 'Perdre du poids',
|
self::LOSE_WEIGHT => __('enums.weight_goal.lose_weight'),
|
||||||
self::MAINTAIN_WEIGHT => 'Maintenir le poids',
|
self::MAINTAIN_WEIGHT => __('enums.weight_goal.maintain_weight'),
|
||||||
self::GAIN_WEIGHT => 'Prendre du poids',
|
self::GAIN_WEIGHT => __('enums.weight_goal.gain_weight'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,28 +22,28 @@ class UserForm
|
||||||
{
|
{
|
||||||
return $schema
|
return $schema
|
||||||
->components([
|
->components([
|
||||||
Section::make('Compte')
|
Section::make(__('admin.users.sections.account'))
|
||||||
->columns(2)
|
->columns(2)
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('name')
|
TextInput::make('name')
|
||||||
->label('Nom')
|
->label(__('admin.users.fields.name'))
|
||||||
->required()
|
->required()
|
||||||
->maxLength(255),
|
->maxLength(255),
|
||||||
TextInput::make('email')
|
TextInput::make('email')
|
||||||
->label('Adresse email')
|
->label(__('admin.users.fields.email'))
|
||||||
->email()
|
->email()
|
||||||
->required()
|
->required()
|
||||||
->unique(ignoreRecord: true)
|
->unique(ignoreRecord: true)
|
||||||
->maxLength(255),
|
->maxLength(255),
|
||||||
FileUpload::make('avatar_url')
|
FileUpload::make('avatar_url')
|
||||||
->label('Avatar')
|
->label(__('admin.users.fields.avatar'))
|
||||||
->image()
|
->image()
|
||||||
->disk('public')
|
->disk('public')
|
||||||
->directory('avatars')
|
->directory('avatars')
|
||||||
->visibility('public')
|
->visibility('public')
|
||||||
->maxSize(2048),
|
->maxSize(2048),
|
||||||
TextInput::make('password')
|
TextInput::make('password')
|
||||||
->label('Mot de passe')
|
->label(__('admin.users.fields.password'))
|
||||||
->password()
|
->password()
|
||||||
->revealable()
|
->revealable()
|
||||||
->rule(Password::default())
|
->rule(Password::default())
|
||||||
|
|
@ -52,38 +52,38 @@ class UserForm
|
||||||
->dehydrated(fn ($state): bool => filled($state))
|
->dehydrated(fn ($state): bool => filled($state))
|
||||||
->autocomplete('new-password'),
|
->autocomplete('new-password'),
|
||||||
DateTimePicker::make('email_verified_at')
|
DateTimePicker::make('email_verified_at')
|
||||||
->label('Email vérifié le'),
|
->label(__('admin.users.fields.email_verified_at')),
|
||||||
DateTimePicker::make('account_verified_at')
|
DateTimePicker::make('account_verified_at')
|
||||||
->label('Compte vérifié le'),
|
->label(__('admin.users.fields.account_verified_at')),
|
||||||
]),
|
]),
|
||||||
Section::make('Profil')
|
Section::make(__('admin.users.sections.profile'))
|
||||||
->columns(2)
|
->columns(2)
|
||||||
->schema([
|
->schema([
|
||||||
Textarea::make('bio')
|
Textarea::make('bio')
|
||||||
->label('Bio')
|
->label(__('admin.users.fields.bio'))
|
||||||
->rows(4)
|
->rows(4)
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
TextInput::make('height')
|
TextInput::make('height')
|
||||||
->label('Taille')
|
->label(__('admin.users.fields.height'))
|
||||||
->integer()
|
->integer()
|
||||||
->minValue(0)
|
->minValue(0)
|
||||||
->maxValue(300)
|
->maxValue(300)
|
||||||
->suffix('cm'),
|
->suffix('cm'),
|
||||||
DatePicker::make('date_of_birth')
|
DatePicker::make('date_of_birth')
|
||||||
->label('Date de naissance')
|
->label(__('admin.users.fields.date_of_birth'))
|
||||||
->minDate('1900-01-01')
|
->minDate('1900-01-01')
|
||||||
->maxDate(now()->subDay()),
|
->maxDate(now()->subDay()),
|
||||||
Select::make('sex')
|
Select::make('sex')
|
||||||
->label('Sexe')
|
->label(__('admin.users.fields.sex'))
|
||||||
->options(UserSex::class)
|
->options(UserSex::class)
|
||||||
->default(UserSex::UNKNOWN->value)
|
->default(UserSex::UNKNOWN->value)
|
||||||
->required(),
|
->required(),
|
||||||
]),
|
]),
|
||||||
Section::make('Objectifs nutritionnels')
|
Section::make(__('admin.users.sections.nutrition_goals'))
|
||||||
->columns(4)
|
->columns(4)
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('daily_calorie_goal')
|
TextInput::make('daily_calorie_goal')
|
||||||
->label('Calories')
|
->label(__('admin.users.fields.daily_calorie_goal'))
|
||||||
->integer()
|
->integer()
|
||||||
->minValue(0)
|
->minValue(0)
|
||||||
->maxValue(100000)
|
->maxValue(100000)
|
||||||
|
|
@ -91,7 +91,7 @@ class UserForm
|
||||||
->default(2000)
|
->default(2000)
|
||||||
->required(),
|
->required(),
|
||||||
TextInput::make('daily_protein_goal')
|
TextInput::make('daily_protein_goal')
|
||||||
->label('Protéines')
|
->label(__('admin.users.fields.daily_protein_goal'))
|
||||||
->numeric()
|
->numeric()
|
||||||
->minValue(0)
|
->minValue(0)
|
||||||
->maxValue(10000)
|
->maxValue(10000)
|
||||||
|
|
@ -99,7 +99,7 @@ class UserForm
|
||||||
->default(120)
|
->default(120)
|
||||||
->required(),
|
->required(),
|
||||||
TextInput::make('daily_carbs_goal')
|
TextInput::make('daily_carbs_goal')
|
||||||
->label('Glucides')
|
->label(__('admin.users.fields.daily_carbs_goal'))
|
||||||
->numeric()
|
->numeric()
|
||||||
->minValue(0)
|
->minValue(0)
|
||||||
->maxValue(10000)
|
->maxValue(10000)
|
||||||
|
|
@ -107,7 +107,7 @@ class UserForm
|
||||||
->default(250)
|
->default(250)
|
||||||
->required(),
|
->required(),
|
||||||
TextInput::make('daily_fats_goal')
|
TextInput::make('daily_fats_goal')
|
||||||
->label('Lipides')
|
->label(__('admin.users.fields.daily_fats_goal'))
|
||||||
->numeric()
|
->numeric()
|
||||||
->minValue(0)
|
->minValue(0)
|
||||||
->maxValue(10000)
|
->maxValue(10000)
|
||||||
|
|
@ -115,21 +115,21 @@ class UserForm
|
||||||
->default(70)
|
->default(70)
|
||||||
->required(),
|
->required(),
|
||||||
]),
|
]),
|
||||||
Section::make('Activité')
|
Section::make(__('admin.users.sections.activity'))
|
||||||
->columns(3)
|
->columns(3)
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('physical_activity_level')
|
Select::make('physical_activity_level')
|
||||||
->label('Niveau d’activité')
|
->label(__('admin.users.fields.physical_activity_level'))
|
||||||
->options(PhysicalActivityLevel::class)
|
->options(PhysicalActivityLevel::class)
|
||||||
->default(PhysicalActivityLevel::SEDENTARY->value)
|
->default(PhysicalActivityLevel::SEDENTARY->value)
|
||||||
->required(),
|
->required(),
|
||||||
Select::make('weight_goal')
|
Select::make('weight_goal')
|
||||||
->label('Objectif de poids')
|
->label(__('admin.users.fields.weight_goal'))
|
||||||
->options(WeightGoal::class)
|
->options(WeightGoal::class)
|
||||||
->default(WeightGoal::LOSE_WEIGHT->value)
|
->default(WeightGoal::LOSE_WEIGHT->value)
|
||||||
->required(),
|
->required(),
|
||||||
Select::make('pace_preference')
|
Select::make('pace_preference')
|
||||||
->label('Rythme')
|
->label(__('admin.users.fields.pace_preference'))
|
||||||
->options(PacePreference::class)
|
->options(PacePreference::class)
|
||||||
->default(PacePreference::SLOW->value)
|
->default(PacePreference::SLOW->value)
|
||||||
->required(),
|
->required(),
|
||||||
|
|
|
||||||
|
|
@ -13,95 +13,95 @@ class UserInfolist
|
||||||
{
|
{
|
||||||
return $schema
|
return $schema
|
||||||
->components([
|
->components([
|
||||||
Section::make('Compte')
|
Section::make(__('admin.users.sections.account'))
|
||||||
->columns(3)
|
->columns(3)
|
||||||
->schema([
|
->schema([
|
||||||
TextEntry::make('id')
|
TextEntry::make('id')
|
||||||
->label('ID')
|
->label(__('admin.users.fields.id'))
|
||||||
->copyable(),
|
->copyable(),
|
||||||
TextEntry::make('name')
|
TextEntry::make('name')
|
||||||
->label('Nom'),
|
->label(__('admin.users.fields.name')),
|
||||||
TextEntry::make('email')
|
TextEntry::make('email')
|
||||||
->label('Adresse email')
|
->label(__('admin.users.fields.email'))
|
||||||
->copyable(),
|
->copyable(),
|
||||||
TextEntry::make('email_verified_at')
|
TextEntry::make('email_verified_at')
|
||||||
->label('Email vérifié le')
|
->label(__('admin.users.fields.email_verified_at'))
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->placeholder('Non vérifié'),
|
->placeholder(__('admin.users.placeholders.not_verified')),
|
||||||
TextEntry::make('account_verified_at')
|
TextEntry::make('account_verified_at')
|
||||||
->label('Compte vérifié le')
|
->label(__('admin.users.fields.account_verified_at'))
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->placeholder('Non vérifié'),
|
->placeholder(__('admin.users.placeholders.not_verified')),
|
||||||
ImageEntry::make('avatar_url')
|
ImageEntry::make('avatar_url')
|
||||||
->label('Avatar')
|
->label(__('admin.users.fields.avatar'))
|
||||||
->disk('public')
|
->disk('public')
|
||||||
->circular()
|
->circular()
|
||||||
->placeholder('-'),
|
->placeholder(__('admin.users.placeholders.empty')),
|
||||||
]),
|
]),
|
||||||
Section::make('Profil')
|
Section::make(__('admin.users.sections.profile'))
|
||||||
->columns(3)
|
->columns(3)
|
||||||
->schema([
|
->schema([
|
||||||
TextEntry::make('bio')
|
TextEntry::make('bio')
|
||||||
->label('Bio')
|
->label(__('admin.users.fields.bio'))
|
||||||
->placeholder('-')
|
->placeholder(__('admin.users.placeholders.empty'))
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
TextEntry::make('height')
|
TextEntry::make('height')
|
||||||
->label('Taille')
|
->label(__('admin.users.fields.height'))
|
||||||
->numeric(decimalPlaces: 0)
|
->numeric(decimalPlaces: 0)
|
||||||
->suffix(' cm')
|
->suffix(' cm')
|
||||||
->placeholder('-'),
|
->placeholder(__('admin.users.placeholders.empty')),
|
||||||
TextEntry::make('date_of_birth')
|
TextEntry::make('date_of_birth')
|
||||||
->label('Date de naissance')
|
->label(__('admin.users.fields.date_of_birth'))
|
||||||
->date()
|
->date()
|
||||||
->placeholder('-'),
|
->placeholder(__('admin.users.placeholders.empty')),
|
||||||
TextEntry::make('sex')
|
TextEntry::make('sex')
|
||||||
->label('Sexe')
|
->label(__('admin.users.fields.sex'))
|
||||||
->badge(),
|
->badge(),
|
||||||
]),
|
]),
|
||||||
Section::make('Objectifs nutritionnels')
|
Section::make(__('admin.users.sections.nutrition_goals'))
|
||||||
->columns(4)
|
->columns(4)
|
||||||
->schema([
|
->schema([
|
||||||
TextEntry::make('daily_calorie_goal')
|
TextEntry::make('daily_calorie_goal')
|
||||||
->label('Calories')
|
->label(__('admin.users.fields.daily_calorie_goal'))
|
||||||
->numeric(decimalPlaces: 0)
|
->numeric(decimalPlaces: 0)
|
||||||
->suffix(' kcal'),
|
->suffix(' kcal'),
|
||||||
TextEntry::make('daily_protein_goal')
|
TextEntry::make('daily_protein_goal')
|
||||||
->label('Protéines')
|
->label(__('admin.users.fields.daily_protein_goal'))
|
||||||
->numeric(maxDecimalPlaces: 2)
|
->numeric(maxDecimalPlaces: 2)
|
||||||
->suffix(' g'),
|
->suffix(' g'),
|
||||||
TextEntry::make('daily_carbs_goal')
|
TextEntry::make('daily_carbs_goal')
|
||||||
->label('Glucides')
|
->label(__('admin.users.fields.daily_carbs_goal'))
|
||||||
->numeric(maxDecimalPlaces: 2)
|
->numeric(maxDecimalPlaces: 2)
|
||||||
->suffix(' g'),
|
->suffix(' g'),
|
||||||
TextEntry::make('daily_fats_goal')
|
TextEntry::make('daily_fats_goal')
|
||||||
->label('Lipides')
|
->label(__('admin.users.fields.daily_fats_goal'))
|
||||||
->numeric(maxDecimalPlaces: 2)
|
->numeric(maxDecimalPlaces: 2)
|
||||||
->suffix(' g'),
|
->suffix(' g'),
|
||||||
]),
|
]),
|
||||||
Section::make('Activité')
|
Section::make(__('admin.users.sections.activity'))
|
||||||
->columns(3)
|
->columns(3)
|
||||||
->schema([
|
->schema([
|
||||||
TextEntry::make('physical_activity_level')
|
TextEntry::make('physical_activity_level')
|
||||||
->label('Niveau d’activité')
|
->label(__('admin.users.fields.physical_activity_level'))
|
||||||
->badge(),
|
->badge(),
|
||||||
TextEntry::make('weight_goal')
|
TextEntry::make('weight_goal')
|
||||||
->label('Objectif de poids')
|
->label(__('admin.users.fields.weight_goal'))
|
||||||
->badge(),
|
->badge(),
|
||||||
TextEntry::make('pace_preference')
|
TextEntry::make('pace_preference')
|
||||||
->label('Rythme')
|
->label(__('admin.users.fields.pace_preference'))
|
||||||
->badge(),
|
->badge(),
|
||||||
]),
|
]),
|
||||||
Section::make('Métadonnées')
|
Section::make(__('admin.users.sections.metadata'))
|
||||||
->columns(2)
|
->columns(2)
|
||||||
->schema([
|
->schema([
|
||||||
TextEntry::make('created_at')
|
TextEntry::make('created_at')
|
||||||
->label('Créé le')
|
->label(__('admin.users.fields.created_at'))
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->placeholder('-'),
|
->placeholder(__('admin.users.placeholders.empty')),
|
||||||
TextEntry::make('updated_at')
|
TextEntry::make('updated_at')
|
||||||
->label('Mis à jour le')
|
->label(__('admin.users.fields.updated_at'))
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->placeholder('-'),
|
->placeholder(__('admin.users.placeholders.empty')),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,118 +23,118 @@ class UsersTable
|
||||||
return $table
|
return $table
|
||||||
->columns([
|
->columns([
|
||||||
TextColumn::make('id')
|
TextColumn::make('id')
|
||||||
->label('ID')
|
->label(__('admin.users.fields.id'))
|
||||||
->searchable()
|
->searchable()
|
||||||
->copyable()
|
->copyable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('name')
|
TextColumn::make('name')
|
||||||
->label('Nom')
|
->label(__('admin.users.fields.name'))
|
||||||
->searchable(),
|
->searchable(),
|
||||||
TextColumn::make('email')
|
TextColumn::make('email')
|
||||||
->label('Adresse email')
|
->label(__('admin.users.fields.email'))
|
||||||
->searchable(),
|
->searchable(),
|
||||||
TextColumn::make('email_verified_at')
|
TextColumn::make('email_verified_at')
|
||||||
->label('Email vérifié le')
|
->label(__('admin.users.fields.email_verified_at'))
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->placeholder('Non vérifié'),
|
->placeholder(__('admin.users.placeholders.not_verified')),
|
||||||
TextColumn::make('account_verified_at')
|
TextColumn::make('account_verified_at')
|
||||||
->label('Compte vérifié le')
|
->label(__('admin.users.fields.account_verified_at'))
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->placeholder('Non vérifié')
|
->placeholder(__('admin.users.placeholders.not_verified'))
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
ImageColumn::make('avatar_url')
|
ImageColumn::make('avatar_url')
|
||||||
->label('Avatar')
|
->label(__('admin.users.fields.avatar'))
|
||||||
->disk('public')
|
->disk('public')
|
||||||
->circular(),
|
->circular(),
|
||||||
TextColumn::make('sex')
|
TextColumn::make('sex')
|
||||||
->label('Sexe')
|
->label(__('admin.users.fields.sex'))
|
||||||
->badge()
|
->badge()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
TextColumn::make('date_of_birth')
|
TextColumn::make('date_of_birth')
|
||||||
->label('Date de naissance')
|
->label(__('admin.users.fields.date_of_birth'))
|
||||||
->date()
|
->date()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('height')
|
TextColumn::make('height')
|
||||||
->label('Taille')
|
->label(__('admin.users.fields.height'))
|
||||||
->numeric(decimalPlaces: 0)
|
->numeric(decimalPlaces: 0)
|
||||||
->suffix(' cm')
|
->suffix(' cm')
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('physical_activity_level')
|
TextColumn::make('physical_activity_level')
|
||||||
->label('Activité')
|
->label(__('admin.users.fields.physical_activity_level_short'))
|
||||||
->badge()
|
->badge()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('weight_goal')
|
TextColumn::make('weight_goal')
|
||||||
->label('Objectif poids')
|
->label(__('admin.users.fields.weight_goal_short'))
|
||||||
->badge()
|
->badge()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('pace_preference')
|
TextColumn::make('pace_preference')
|
||||||
->label('Rythme')
|
->label(__('admin.users.fields.pace_preference'))
|
||||||
->badge()
|
->badge()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('daily_calorie_goal')
|
TextColumn::make('daily_calorie_goal')
|
||||||
->label('Calories')
|
->label(__('admin.users.fields.daily_calorie_goal'))
|
||||||
->numeric(decimalPlaces: 0)
|
->numeric(decimalPlaces: 0)
|
||||||
->suffix(' kcal')
|
->suffix(' kcal')
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('daily_protein_goal')
|
TextColumn::make('daily_protein_goal')
|
||||||
->label('Protéines')
|
->label(__('admin.users.fields.daily_protein_goal'))
|
||||||
->numeric(maxDecimalPlaces: 2)
|
->numeric(maxDecimalPlaces: 2)
|
||||||
->suffix(' g')
|
->suffix(' g')
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('daily_carbs_goal')
|
TextColumn::make('daily_carbs_goal')
|
||||||
->label('Glucides')
|
->label(__('admin.users.fields.daily_carbs_goal'))
|
||||||
->numeric(maxDecimalPlaces: 2)
|
->numeric(maxDecimalPlaces: 2)
|
||||||
->suffix(' g')
|
->suffix(' g')
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('daily_fats_goal')
|
TextColumn::make('daily_fats_goal')
|
||||||
->label('Lipides')
|
->label(__('admin.users.fields.daily_fats_goal'))
|
||||||
->numeric(maxDecimalPlaces: 2)
|
->numeric(maxDecimalPlaces: 2)
|
||||||
->suffix(' g')
|
->suffix(' g')
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('bio')
|
TextColumn::make('bio')
|
||||||
->label('Bio')
|
->label(__('admin.users.fields.bio'))
|
||||||
->limit(50)
|
->limit(50)
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('created_at')
|
TextColumn::make('created_at')
|
||||||
->label('Créé le')
|
->label(__('admin.users.fields.created_at'))
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('updated_at')
|
TextColumn::make('updated_at')
|
||||||
->label('Mis à jour le')
|
->label(__('admin.users.fields.updated_at'))
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
SelectFilter::make('sex')
|
SelectFilter::make('sex')
|
||||||
->label('Sexe')
|
->label(__('admin.users.fields.sex'))
|
||||||
->options(UserSex::class),
|
->options(UserSex::class),
|
||||||
SelectFilter::make('physical_activity_level')
|
SelectFilter::make('physical_activity_level')
|
||||||
->label('Activité')
|
->label(__('admin.users.fields.physical_activity_level_short'))
|
||||||
->options(PhysicalActivityLevel::class),
|
->options(PhysicalActivityLevel::class),
|
||||||
SelectFilter::make('weight_goal')
|
SelectFilter::make('weight_goal')
|
||||||
->label('Objectif poids')
|
->label(__('admin.users.fields.weight_goal_short'))
|
||||||
->options(WeightGoal::class),
|
->options(WeightGoal::class),
|
||||||
SelectFilter::make('pace_preference')
|
SelectFilter::make('pace_preference')
|
||||||
->label('Rythme')
|
->label(__('admin.users.fields.pace_preference'))
|
||||||
->options(PacePreference::class),
|
->options(PacePreference::class),
|
||||||
TernaryFilter::make('email_verified_at')
|
TernaryFilter::make('email_verified_at')
|
||||||
->label('Email vérifié')
|
->label(__('admin.users.filters.email_verified'))
|
||||||
->nullable(),
|
->nullable(),
|
||||||
TernaryFilter::make('account_verified_at')
|
TernaryFilter::make('account_verified_at')
|
||||||
->label('Compte vérifié')
|
->label(__('admin.users.filters.account_verified'))
|
||||||
->nullable(),
|
->nullable(),
|
||||||
])
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,21 @@ class UserResource extends Resource
|
||||||
|
|
||||||
protected static ?string $recordTitleAttribute = 'name';
|
protected static ?string $recordTitleAttribute = 'name';
|
||||||
|
|
||||||
|
public static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return __('admin.users.navigation.label');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('admin.users.navigation.singular');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPluralModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('admin.users.navigation.plural');
|
||||||
|
}
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
public static function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return UserForm::configure($schema);
|
return UserForm::configure($schema);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class SetLocale
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
app()->setLocale($this->resolveLocale($request));
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function resolveLocale(Request $request): string
|
||||||
|
{
|
||||||
|
$supportedLocales = config('app.supported_locales', ['fr', 'en']);
|
||||||
|
$requestedLocale = $request->query('locale') ?: $request->header('X-Locale');
|
||||||
|
|
||||||
|
if (is_string($requestedLocale)) {
|
||||||
|
$normalizedLocale = $this->normalizeLocale($requestedLocale);
|
||||||
|
|
||||||
|
if (in_array($normalizedLocale, $supportedLocales, true)) {
|
||||||
|
return $normalizedLocale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $request->getPreferredLanguage($supportedLocales) ?? config('app.locale');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function normalizeLocale(string $locale): string
|
||||||
|
{
|
||||||
|
$locale = strtolower(str_replace('_', '-', $locale));
|
||||||
|
|
||||||
|
return explode('-', $locale)[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -25,9 +25,13 @@ class UserResource extends JsonResource
|
||||||
'bio' => $this->bio,
|
'bio' => $this->bio,
|
||||||
'accountVerified' => $this->account_verified_at !== null,
|
'accountVerified' => $this->account_verified_at !== null,
|
||||||
'physicalActivityLevel' => $this->physical_activity_level,
|
'physicalActivityLevel' => $this->physical_activity_level,
|
||||||
|
'physicalActivityLevelLabel' => $this->physical_activity_level?->getLabel(),
|
||||||
'weightGoal' => $this->weight_goal,
|
'weightGoal' => $this->weight_goal,
|
||||||
|
'weightGoalLabel' => $this->weight_goal?->getLabel(),
|
||||||
'pacePreference' => $this->pace_preference,
|
'pacePreference' => $this->pace_preference,
|
||||||
|
'pacePreferenceLabel' => $this->pace_preference?->getLabel(),
|
||||||
'sex' => $this->sex,
|
'sex' => $this->sex,
|
||||||
|
'sexLabel' => $this->sex?->getLabel(),
|
||||||
'dateOfBirth' => $this->date_of_birth?->toDateString(),
|
'dateOfBirth' => $this->date_of_birth?->toDateString(),
|
||||||
'nutritionGoals' => [
|
'nutritionGoals' => [
|
||||||
'calories' => (int) $this->daily_calorie_goal,
|
'calories' => (int) $this->daily_calorie_goal,
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ return Application::configure(basePath: dirname(__DIR__))
|
||||||
)
|
)
|
||||||
->withMiddleware(function (Middleware $middleware): void {
|
->withMiddleware(function (Middleware $middleware): void {
|
||||||
$middleware->prepend(\App\Http\Middleware\AuthenticateWithCookie::class);
|
$middleware->prepend(\App\Http\Middleware\AuthenticateWithCookie::class);
|
||||||
|
$middleware->prepend(\App\Http\Middleware\SetLocale::class);
|
||||||
$middleware->alias([
|
$middleware->alias([
|
||||||
'verified' => \App\Http\Middleware\EnsureEmailIsVerified::class,
|
'verified' => \App\Http\Middleware\EnsureEmailIsVerified::class,
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,8 @@ return [
|
||||||
|
|
||||||
'locale' => env('APP_LOCALE', 'fr'),
|
'locale' => env('APP_LOCALE', 'fr'),
|
||||||
|
|
||||||
|
'supported_locales' => ['fr', 'en'],
|
||||||
|
|
||||||
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||||
|
|
||||||
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'users' => [
|
||||||
|
'navigation' => [
|
||||||
|
'label' => 'Users',
|
||||||
|
'singular' => 'User',
|
||||||
|
'plural' => 'Users',
|
||||||
|
],
|
||||||
|
'sections' => [
|
||||||
|
'account' => 'Account',
|
||||||
|
'profile' => 'Profile',
|
||||||
|
'nutrition_goals' => 'Nutrition goals',
|
||||||
|
'activity' => 'Activity',
|
||||||
|
'metadata' => 'Metadata',
|
||||||
|
],
|
||||||
|
'fields' => [
|
||||||
|
'id' => 'ID',
|
||||||
|
'name' => 'Name',
|
||||||
|
'email' => 'Email address',
|
||||||
|
'email_verified_at' => 'Email verified at',
|
||||||
|
'account_verified_at' => 'Account verified at',
|
||||||
|
'avatar' => 'Avatar',
|
||||||
|
'password' => 'Password',
|
||||||
|
'bio' => 'Bio',
|
||||||
|
'height' => 'Height',
|
||||||
|
'date_of_birth' => 'Date of birth',
|
||||||
|
'sex' => 'Sex',
|
||||||
|
'daily_calorie_goal' => 'Calories',
|
||||||
|
'daily_protein_goal' => 'Protein',
|
||||||
|
'daily_carbs_goal' => 'Carbs',
|
||||||
|
'daily_fats_goal' => 'Fats',
|
||||||
|
'physical_activity_level' => 'Activity level',
|
||||||
|
'physical_activity_level_short' => 'Activity',
|
||||||
|
'weight_goal' => 'Weight goal',
|
||||||
|
'weight_goal_short' => 'Weight goal',
|
||||||
|
'pace_preference' => 'Pace',
|
||||||
|
'created_at' => 'Created at',
|
||||||
|
'updated_at' => 'Updated at',
|
||||||
|
],
|
||||||
|
'filters' => [
|
||||||
|
'email_verified' => 'Email verified',
|
||||||
|
'account_verified' => 'Account verified',
|
||||||
|
],
|
||||||
|
'placeholders' => [
|
||||||
|
'not_verified' => 'Not verified',
|
||||||
|
'empty' => '-',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'pace_preference' => [
|
||||||
|
'slow' => 'Slow',
|
||||||
|
'normal' => 'Normal',
|
||||||
|
'fast' => 'Fast',
|
||||||
|
],
|
||||||
|
'physical_activity_level' => [
|
||||||
|
'sedentary' => 'Sedentary',
|
||||||
|
'lightly_active' => 'Lightly active',
|
||||||
|
'moderately_active' => 'Moderately active',
|
||||||
|
'very_active' => 'Very active',
|
||||||
|
'athlete' => 'Athlete',
|
||||||
|
],
|
||||||
|
'user_sex' => [
|
||||||
|
'man' => 'Man',
|
||||||
|
'woman' => 'Woman',
|
||||||
|
'other' => 'Other',
|
||||||
|
'unknown' => 'Not specified',
|
||||||
|
],
|
||||||
|
'weight_goal' => [
|
||||||
|
'lose_weight' => 'Lose weight',
|
||||||
|
'maintain_weight' => 'Maintain weight',
|
||||||
|
'gain_weight' => 'Gain weight',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'users' => [
|
||||||
|
'navigation' => [
|
||||||
|
'label' => 'Utilisateurs',
|
||||||
|
'singular' => 'Utilisateur',
|
||||||
|
'plural' => 'Utilisateurs',
|
||||||
|
],
|
||||||
|
'sections' => [
|
||||||
|
'account' => 'Compte',
|
||||||
|
'profile' => 'Profil',
|
||||||
|
'nutrition_goals' => 'Objectifs nutritionnels',
|
||||||
|
'activity' => 'Activité',
|
||||||
|
'metadata' => 'Métadonnées',
|
||||||
|
],
|
||||||
|
'fields' => [
|
||||||
|
'id' => 'ID',
|
||||||
|
'name' => 'Nom',
|
||||||
|
'email' => 'Adresse email',
|
||||||
|
'email_verified_at' => 'Email vérifié le',
|
||||||
|
'account_verified_at' => 'Compte vérifié le',
|
||||||
|
'avatar' => 'Avatar',
|
||||||
|
'password' => 'Mot de passe',
|
||||||
|
'bio' => 'Bio',
|
||||||
|
'height' => 'Taille',
|
||||||
|
'date_of_birth' => 'Date de naissance',
|
||||||
|
'sex' => 'Sexe',
|
||||||
|
'daily_calorie_goal' => 'Calories',
|
||||||
|
'daily_protein_goal' => 'Protéines',
|
||||||
|
'daily_carbs_goal' => 'Glucides',
|
||||||
|
'daily_fats_goal' => 'Lipides',
|
||||||
|
'physical_activity_level' => 'Niveau d’activité',
|
||||||
|
'physical_activity_level_short' => 'Activité',
|
||||||
|
'weight_goal' => 'Objectif de poids',
|
||||||
|
'weight_goal_short' => 'Objectif poids',
|
||||||
|
'pace_preference' => 'Rythme',
|
||||||
|
'created_at' => 'Créé le',
|
||||||
|
'updated_at' => 'Mis à jour le',
|
||||||
|
],
|
||||||
|
'filters' => [
|
||||||
|
'email_verified' => 'Email vérifié',
|
||||||
|
'account_verified' => 'Compte vérifié',
|
||||||
|
],
|
||||||
|
'placeholders' => [
|
||||||
|
'not_verified' => 'Non vérifié',
|
||||||
|
'empty' => '-',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'pace_preference' => [
|
||||||
|
'slow' => 'Lent',
|
||||||
|
'normal' => 'Normal',
|
||||||
|
'fast' => 'Rapide',
|
||||||
|
],
|
||||||
|
'physical_activity_level' => [
|
||||||
|
'sedentary' => 'Sédentaire',
|
||||||
|
'lightly_active' => 'Légèrement actif',
|
||||||
|
'moderately_active' => 'Modérément actif',
|
||||||
|
'very_active' => 'Très actif',
|
||||||
|
'athlete' => 'Athlète',
|
||||||
|
],
|
||||||
|
'user_sex' => [
|
||||||
|
'man' => 'Homme',
|
||||||
|
'woman' => 'Femme',
|
||||||
|
'other' => 'Autre',
|
||||||
|
'unknown' => 'Non renseigné',
|
||||||
|
],
|
||||||
|
'weight_goal' => [
|
||||||
|
'lose_weight' => 'Perdre du poids',
|
||||||
|
'maintain_weight' => 'Maintenir le poids',
|
||||||
|
'gain_weight' => 'Prendre du poids',
|
||||||
|
],
|
||||||
|
];
|
||||||
Loading…
Reference in New Issue