feat(Password process for new admin, cleaning translations)
All checks were successful
Deploy Roxane to Preprod / deploy (push) Successful in 1m21s
All checks were successful
Deploy Roxane to Preprod / deploy (push) Successful in 1m21s
This commit is contained in:
@@ -3,22 +3,22 @@
|
||||
namespace App\Filament\Resources\Members\Schemas;
|
||||
|
||||
use App\Enums\IspconfigType;
|
||||
use App\Filament\Actions\ServiceToggleAction;
|
||||
use App\Models\Member;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Infolists\Components\ViewEntry;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Infolists\Components\RepeatableEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Infolists\Components\ViewEntry;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use App\Filament\Actions\ServiceToggleAction;
|
||||
|
||||
class MemberForm
|
||||
{
|
||||
@@ -42,10 +42,10 @@ class MemberForm
|
||||
| TAB : Informations générales
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
Tabs\Tab::make('Informations générales')
|
||||
Tabs\Tab::make(__('members.tabs.general_info'))
|
||||
->icon(Heroicon::OutlinedInformationCircle)
|
||||
->schema([
|
||||
Section::make('Informations personnelles')
|
||||
Section::make(__('members.sections.personal_info'))
|
||||
->collapsible()
|
||||
->schema([
|
||||
TextInput::make('lastname')
|
||||
@@ -64,7 +64,7 @@ class MemberForm
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Section::make('Informations administratives')
|
||||
Section::make(__('members.sections.administrative_info'))
|
||||
->collapsible()
|
||||
->schema([
|
||||
TextInput::make('keycloak_id')
|
||||
@@ -86,7 +86,7 @@ class MemberForm
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Section::make('Coordonnées')
|
||||
Section::make(__('members.sections.contact_info'))
|
||||
->collapsible()
|
||||
->schema([
|
||||
TextInput::make('email')
|
||||
@@ -122,143 +122,135 @@ class MemberForm
|
||||
| TAB : Services/Modules
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
Tabs\Tab::make('Modules')
|
||||
Tabs\Tab::make(__('members.tabs.modules'))
|
||||
->icon(Heroicon::OutlinedPuzzlePiece)
|
||||
->schema([
|
||||
/*
|
||||
| Messageries ISPConfig (lecture seule)
|
||||
*/
|
||||
Section::make('Messagerie ISPConfig')
|
||||
Section::make(__('members.sections.ispconfig_mail'))
|
||||
->afterHeader([
|
||||
ServiceToggleAction::forService('mail'),
|
||||
])
|
||||
->collapsible()
|
||||
->schema([
|
||||
RepeatableEntry::make('ispconfig_mails')
|
||||
->label('Données ISPConfig Mail')
|
||||
->state(fn(?Member $record) => $record?->ispconfigs()
|
||||
->label(__('members.ispconfig.mail_data'))
|
||||
->state(fn (?Member $record) => $record?->ispconfigs()
|
||||
->where('type', IspconfigType::MAIL)
|
||||
->get()
|
||||
)
|
||||
->schema([
|
||||
TextEntry::make('email')
|
||||
->label('Adresse email'),
|
||||
->label(__('members.ispconfig.email')),
|
||||
|
||||
TextEntry::make('ispconfig_service_user_id')
|
||||
->label('ID ISPConfig'),
|
||||
->label(__('members.ispconfig.id')),
|
||||
|
||||
TextEntry::make('data.mailuser.quota')
|
||||
->label('Quota'),
|
||||
//->formatStateUsing(fn($state) => $state ? "{$state} Mo" : 'Non défini'
|
||||
//),
|
||||
->label(__('members.ispconfig.quota')),
|
||||
|
||||
TextEntry::make('data.mailuser.domain')
|
||||
->label('Domaine')
|
||||
->label(__('members.ispconfig.domain'))
|
||||
->default('retzien.fr'),
|
||||
ViewEntry::make('data')
|
||||
->label('JSON')
|
||||
->view('filament.components.json-viewer')
|
||||
->viewData(fn($state) => [
|
||||
->viewData(fn ($state) => [
|
||||
'data' => $state,
|
||||
])
|
||||
->columnSpanFull(),
|
||||
])
|
||||
->columns(2),
|
||||
])
|
||||
->visible(fn(?Member $record) => $record?->ispconfigs()
|
||||
->visible(fn (?Member $record) => $record?->ispconfigs()
|
||||
->where('type', IspconfigType::MAIL)
|
||||
->exists()
|
||||
),
|
||||
|
||||
/*
|
||||
| Hébergements web ISPConfig
|
||||
*/
|
||||
Section::make('Hébergements Web')
|
||||
Section::make(__('members.sections.ispconfig_web'))
|
||||
->afterHeader([
|
||||
ServiceToggleAction::forService('webhosting'),
|
||||
])
|
||||
->collapsible()
|
||||
->schema([
|
||||
RepeatableEntry::make('ispconfigs_web')
|
||||
->label('Données ISPConfig Web')
|
||||
->state(fn(?Member $record) => $record?->ispconfigs()
|
||||
->label(__('members.ispconfig.web_data'))
|
||||
->state(fn (?Member $record) => $record?->ispconfigs()
|
||||
->where('type', IspconfigType::WEB)
|
||||
->get()
|
||||
->map(fn($ispconfig) => $ispconfig->toArray())
|
||||
->map(fn ($ispconfig) => $ispconfig->toArray())
|
||||
->all()
|
||||
)
|
||||
->schema([
|
||||
TextEntry::make('data.domain_id')
|
||||
->label('ID ISPConfig'),
|
||||
->label(__('members.ispconfig.id')),
|
||||
|
||||
TextEntry::make('data.domain')
|
||||
->label('Domaine'),
|
||||
->label(__('members.ispconfig.domain')),
|
||||
|
||||
TextEntry::make('data.active')
|
||||
->label('État')
|
||||
->formatStateUsing(fn($state) => $state === 'y' ? 'Activé' : 'Désactivé'
|
||||
->label(__('members.ispconfig.state'))
|
||||
->formatStateUsing(fn ($state) => $state === 'y'
|
||||
? __('members.ispconfig.enabled')
|
||||
: __('members.ispconfig.disabled')
|
||||
),
|
||||
ViewEntry::make('data')
|
||||
->label('JSON')
|
||||
->view('filament.components.json-viewer')
|
||||
->viewData(fn($state) => [
|
||||
->viewData(fn ($state) => [
|
||||
'data' => $state,
|
||||
])
|
||||
->columnSpanFull(),
|
||||
// @todo: background color : #F5F8FA
|
||||
])
|
||||
->columns(3),
|
||||
|
||||
])
|
||||
->visible(fn(?Member $record) => $record?->ispconfigs()
|
||||
->visible(fn (?Member $record) => $record?->ispconfigs()
|
||||
->where('type', IspconfigType::WEB)
|
||||
->exists()
|
||||
),
|
||||
|
||||
/*
|
||||
| Compte(s) NextCloud (lecture seule)
|
||||
*/
|
||||
Section::make('NextCloud')
|
||||
Section::make(__('members.sections.nextcloud'))
|
||||
->afterHeader([
|
||||
ServiceToggleAction::forService('nextcloud'),
|
||||
])
|
||||
->collapsible()
|
||||
->schema([
|
||||
RepeatableEntry::make('nextcloud_accounts')
|
||||
->label('Données NextCloud')
|
||||
->state(fn(?Member $record) => $record?->nextcloudAccounts()
|
||||
->label(__('members.ispconfig.nextcloud_data'))
|
||||
->state(fn (?Member $record) => $record?->nextcloudAccounts()
|
||||
->get()
|
||||
->map(fn($nextcloudAccount) => $nextcloudAccount->toArray())
|
||||
->map(fn ($nextcloudAccount) => $nextcloudAccount->toArray())
|
||||
->all()
|
||||
)
|
||||
->schema([
|
||||
TextEntry::make('nextcloud_user_id')
|
||||
->label('Id Nextcloud'),
|
||||
->label(__('members.ispconfig.nextcloud_id')),
|
||||
|
||||
TextEntry::make('data.displayname')
|
||||
->label('Nom de l\'utilisateur'),
|
||||
->label(__('members.ispconfig.display_name')),
|
||||
|
||||
TextEntry::make('data.enabled')
|
||||
->label('État')
|
||||
->formatStateUsing(fn($state) => $state == 'true' ? 'Activé' : 'Désactivé'
|
||||
->label(__('members.ispconfig.state'))
|
||||
->formatStateUsing(fn ($state) => $state == 'true'
|
||||
? __('members.ispconfig.enabled')
|
||||
: __('members.ispconfig.disabled')
|
||||
),
|
||||
|
||||
ViewEntry::make('data')
|
||||
->label('JSON')
|
||||
->view('filament.components.json-viewer')
|
||||
->viewData(fn($state) => [
|
||||
->viewData(fn ($state) => [
|
||||
'data' => $state,
|
||||
])
|
||||
->columnSpanFull(),
|
||||
])
|
||||
->columns(3),
|
||||
])
|
||||
->visible(fn(?Member $record) => $record?->nextcloudAccounts()
|
||||
->visible(fn (?Member $record) => $record?->nextcloudAccounts()
|
||||
->exists()
|
||||
),
|
||||
]),
|
||||
])
|
||||
->contained(false)
|
||||
->contained(false),
|
||||
])
|
||||
->columnSpan(3),
|
||||
|
||||
@@ -269,7 +261,7 @@ class MemberForm
|
||||
*/
|
||||
Grid::make(1)
|
||||
->schema([
|
||||
Section::make('Statut')
|
||||
Section::make(__('members.sections.status'))
|
||||
->collapsible()
|
||||
->schema([
|
||||
Select::make('status')
|
||||
@@ -290,18 +282,18 @@ class MemberForm
|
||||
])
|
||||
->extraAttributes(['class' => 'sticky top-4 h-fit']),
|
||||
|
||||
Section::make('Actions')
|
||||
Section::make(__('members.sections.actions'))
|
||||
->collapsible()
|
||||
->schema([
|
||||
Action::make('send-payment-mail')
|
||||
->label('Envoyer le mail de paiement')
|
||||
->label(__('members.actions.send_payment_mail'))
|
||||
->icon('heroicon-o-envelope')
|
||||
->action(function () {
|
||||
// Mail de paiement pour nouvelle inscription (Job)
|
||||
}),
|
||||
|
||||
Action::make('send-renewal-mail')
|
||||
->label('Envoyer un mail de relance')
|
||||
->label(__('members.actions.send_renewal_mail'))
|
||||
->icon('heroicon-o-envelope')
|
||||
->action(function () {
|
||||
// Mail de relance à créer (Job)
|
||||
|
||||
@@ -40,14 +40,14 @@ class MembershipForm
|
||||
| TAB : Informations générales
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
Tabs\Tab::make('Informations générales')
|
||||
Tabs\Tab::make(__('memberships.tabs.general_info'))
|
||||
->icon(Heroicon::OutlinedInformationCircle)
|
||||
->schema([
|
||||
Section::make('Adhérent')
|
||||
Section::make(__('memberships.sections.member'))
|
||||
->headerActions([
|
||||
Action::make('view-profile')
|
||||
->icon('heroicon-o-user')
|
||||
->label('Voir le profil du membre')
|
||||
->label(__('memberships.actions.view_profile'))
|
||||
->action(function (Membership $record) {
|
||||
return redirect()->route('filament.admin.resources.members.edit', ['record' => $record->member_id]);
|
||||
}),
|
||||
@@ -62,7 +62,7 @@ class MembershipForm
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Section::make('Informations de transaction')
|
||||
Section::make(__('memberships.sections.transaction'))
|
||||
->schema([
|
||||
Select::make('package_id')
|
||||
->label(Membership::getAttributeLabel('package_id'))
|
||||
@@ -89,136 +89,131 @@ class MembershipForm
|
||||
| TAB : Services/Modules
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
Tabs\Tab::make('Modules')
|
||||
Tabs\Tab::make(__('memberships.tabs.modules'))
|
||||
->icon(Heroicon::OutlinedPuzzlePiece)
|
||||
->schema([
|
||||
/*
|
||||
| Messageries ISPConfig (lecture seule)
|
||||
*/
|
||||
Section::make('Messagerie ISPConfig')
|
||||
Section::make(__('memberships.sections.ispconfig_mail'))
|
||||
->afterHeader([
|
||||
ServiceToggleAction::forService('mail'),
|
||||
])
|
||||
->collapsible()
|
||||
->schema([
|
||||
RepeatableEntry::make('ispconfig_mails')
|
||||
->label('Données ISPConfig Mail')
|
||||
->state(fn(?Membership $record) => $record?->member?->ispconfigs()
|
||||
->label(__('members.ispconfig.mail_data'))
|
||||
->state(fn (?Membership $record) => $record?->member?->ispconfigs()
|
||||
->where('type', IspconfigType::MAIL)
|
||||
->get()
|
||||
)
|
||||
->schema([
|
||||
TextEntry::make('email')
|
||||
->label('Adresse email'),
|
||||
->label(__('members.ispconfig.email')),
|
||||
|
||||
TextEntry::make('ispconfig_service_user_id')
|
||||
->label('ID ISPConfig'),
|
||||
->label(__('members.ispconfig.id')),
|
||||
|
||||
TextEntry::make('data.mailuser.quota')
|
||||
->label('Quota'),
|
||||
->label(__('members.ispconfig.quota')),
|
||||
|
||||
TextEntry::make('data.mailuser.domain')
|
||||
->label('Domaine')
|
||||
->label(__('members.ispconfig.domain'))
|
||||
->default('retzien.fr'),
|
||||
|
||||
ViewEntry::make('data')
|
||||
->label('JSON')
|
||||
->view('filament.components.json-viewer')
|
||||
->viewData(fn($state) => [
|
||||
->viewData(fn ($state) => [
|
||||
'data' => $state,
|
||||
])
|
||||
->columnSpanFull(),
|
||||
])
|
||||
->columns(2),
|
||||
])
|
||||
->visible(fn(?Membership $record) => $record?->member?->ispconfigs()
|
||||
->visible(fn (?Membership $record) => $record?->member?->ispconfigs()
|
||||
->where('type', IspconfigType::MAIL)
|
||||
->exists() ?? false
|
||||
),
|
||||
|
||||
/*
|
||||
| Hébergements web ISPConfig
|
||||
*/
|
||||
Section::make('Hébergements Web')
|
||||
Section::make(__('memberships.sections.ispconfig_web'))
|
||||
->afterHeader([
|
||||
ServiceToggleAction::forService('webhosting'),
|
||||
])
|
||||
->collapsible()
|
||||
->schema([
|
||||
RepeatableEntry::make('ispconfigs_web')
|
||||
->label('Données ISPConfig Web')
|
||||
->state(fn(?Membership $record) => $record?->member?->ispconfigs()
|
||||
->label(__('members.ispconfig.web_data'))
|
||||
->state(fn (?Membership $record) => $record?->member?->ispconfigs()
|
||||
->where('type', IspconfigType::WEB)
|
||||
->get()
|
||||
->map(fn($ispconfig) => $ispconfig->toArray())
|
||||
->map(fn ($ispconfig) => $ispconfig->toArray())
|
||||
->all()
|
||||
)
|
||||
->schema([
|
||||
TextEntry::make('data.domain_id')
|
||||
->label('ID ISPConfig'),
|
||||
->label(__('members.ispconfig.id')),
|
||||
|
||||
TextEntry::make('data.domain')
|
||||
->label('Domaine'),
|
||||
->label(__('members.ispconfig.domain')),
|
||||
|
||||
TextEntry::make('data.active')
|
||||
->label('État')
|
||||
->formatStateUsing(fn($state) => $state === 'y' ? 'Activé' : 'Désactivé'
|
||||
->label(__('members.ispconfig.state'))
|
||||
->formatStateUsing(fn ($state) => $state === 'y'
|
||||
? __('members.ispconfig.enabled')
|
||||
: __('members.ispconfig.disabled')
|
||||
),
|
||||
|
||||
ViewEntry::make('data')
|
||||
->label('JSON')
|
||||
->view('filament.components.json-viewer')
|
||||
->viewData(fn($state) => [
|
||||
->viewData(fn ($state) => [
|
||||
'data' => $state,
|
||||
])
|
||||
->columnSpanFull(),
|
||||
])
|
||||
->columns(3),
|
||||
])
|
||||
->visible(fn(?Membership $record) => $record?->member?->ispconfigs()
|
||||
->visible(fn (?Membership $record) => $record?->member?->ispconfigs()
|
||||
->where('type', IspconfigType::WEB)
|
||||
->exists() ?? false
|
||||
),
|
||||
|
||||
/*
|
||||
| Compte(s) NextCloud (lecture seule)
|
||||
*/
|
||||
Section::make('NextCloud')
|
||||
Section::make(__('memberships.sections.nextcloud'))
|
||||
->afterHeader([
|
||||
ServiceToggleAction::forService('nextcloud'),
|
||||
])
|
||||
->collapsible()
|
||||
->schema([
|
||||
RepeatableEntry::make('nextcloud_accounts')
|
||||
->label('Données NextCloud')
|
||||
->state(fn(?Membership $record) => $record?->member?->nextcloudAccounts()
|
||||
->label(__('members.ispconfig.nextcloud_data'))
|
||||
->state(fn (?Membership $record) => $record?->member?->nextcloudAccounts()
|
||||
->get()
|
||||
->map(fn($nextcloudAccount) => $nextcloudAccount->toArray())
|
||||
->map(fn ($nextcloudAccount) => $nextcloudAccount->toArray())
|
||||
->all()
|
||||
)
|
||||
->schema([
|
||||
TextEntry::make('nextcloud_user_id')
|
||||
->label('Id Nextcloud'),
|
||||
->label(__('members.ispconfig.nextcloud_id')),
|
||||
|
||||
TextEntry::make('data.displayname')
|
||||
->label('Nom de l\'utilisateur'),
|
||||
->label(__('members.ispconfig.display_name')),
|
||||
|
||||
TextEntry::make('data.enabled')
|
||||
->label('État')
|
||||
->formatStateUsing(fn($state) => $state == 'true' ? 'Activé' : 'Désactivé'
|
||||
->label(__('members.ispconfig.state'))
|
||||
->formatStateUsing(fn ($state) => $state == 'true'
|
||||
? __('members.ispconfig.enabled')
|
||||
: __('members.ispconfig.disabled')
|
||||
),
|
||||
|
||||
ViewEntry::make('data')
|
||||
->label('JSON')
|
||||
->view('filament.components.json-viewer')
|
||||
->viewData(fn($state) => [
|
||||
->viewData(fn ($state) => [
|
||||
'data' => $state,
|
||||
])
|
||||
->columnSpanFull(),
|
||||
])
|
||||
->columns(3),
|
||||
])
|
||||
->visible(fn(?Membership $record) => $record?->member?->nextcloudAccounts()
|
||||
->visible(fn (?Membership $record) => $record?->member?->nextcloudAccounts()
|
||||
->exists() ?? false
|
||||
),
|
||||
]),
|
||||
@@ -234,7 +229,7 @@ class MembershipForm
|
||||
*/
|
||||
Grid::make(1)
|
||||
->schema([
|
||||
Section::make('Statut')
|
||||
Section::make(__('memberships.sections.status'))
|
||||
->schema([
|
||||
Select::make('status')
|
||||
->label(Membership::getAttributeLabel('status'))
|
||||
|
||||
@@ -11,7 +11,6 @@ use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\QueryBuilder;
|
||||
use Filament\Tables\Filters\QueryBuilder\Constraints\DateConstraint;
|
||||
use Filament\Tables\Filters\QueryBuilder\Constraints\SelectConstraint;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class MembershipsTable
|
||||
@@ -84,29 +83,27 @@ class MembershipsTable
|
||||
'amount',
|
||||
])
|
||||
->filters([
|
||||
// Filtres pour status, date de début et date de fin, status de paiement
|
||||
|
||||
QueryBuilder::make()
|
||||
->constraints([
|
||||
SelectConstraint::make('status')
|
||||
->label('Statut de l\'adhésion')
|
||||
->label(Membership::getAttributeLabel('status'))
|
||||
->options([
|
||||
'active' => 'Active',
|
||||
'expired' => 'Expirée',
|
||||
'pending' => 'En attente',
|
||||
'active' => Membership::getAttributeLabel('active'),
|
||||
'expired' => Membership::getAttributeLabel('expired'),
|
||||
'pending' => Membership::getAttributeLabel('pending'),
|
||||
]),
|
||||
DateConstraint::make('start_date')
|
||||
->label('Date de début'),
|
||||
->label(Membership::getAttributeLabel('start_date')),
|
||||
DateConstraint::make('end_date')
|
||||
->label('Date de fin'),
|
||||
->label(Membership::getAttributeLabel('end_date')),
|
||||
SelectConstraint::make('payment_status')
|
||||
->label('Statut de paiement')
|
||||
->label(Membership::getAttributeLabel('payment_status'))
|
||||
->options([
|
||||
'paid' => 'Payée',
|
||||
'unpaid' => 'Impayée',
|
||||
'partial' => 'Partiellement payée'
|
||||
'paid' => Membership::getAttributeLabel('paid'),
|
||||
'unpaid' => Membership::getAttributeLabel('unpaid'),
|
||||
'partial' => Membership::getAttributeLabel('partial'),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
], layout: FiltersLayout::Modal)
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
|
||||
@@ -32,11 +32,15 @@ class NotificationTemplateForm
|
||||
TextInput::make('subject')
|
||||
->label(NotificationTemplate::getAttributeLabel('subject'))
|
||||
->required()
|
||||
->helperText('Variables : {member_name}, {expiry_date}'),
|
||||
->helperText(fn (?NotificationTemplate $record) => $record?->variables
|
||||
? NotificationTemplate::getAttributeLabel('variables').' : '.implode(', ', array_map(fn ($k) => '{'.$k.'}', array_keys($record->variables)))
|
||||
: null),
|
||||
RichEditor::make('body')
|
||||
->label(NotificationTemplate::getAttributeLabel('body'))
|
||||
->required()
|
||||
->helperText('Variables : {member_name}, {expiry_date}')
|
||||
->helperText(fn (?NotificationTemplate $record) => $record?->variables
|
||||
? NotificationTemplate::getAttributeLabel('variables').' : '.implode(', ', array_map(fn ($k) => '{'.$k.'}', array_keys($record->variables)))
|
||||
: null)
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
]);
|
||||
|
||||
@@ -7,14 +7,12 @@ use App\Filament\Resources\Packages\Pages\EditPackage;
|
||||
use App\Filament\Resources\Packages\Pages\ListPackages;
|
||||
use App\Filament\Resources\Packages\Schemas\PackageForm;
|
||||
use App\Filament\Resources\Packages\Tables\PackagesTable;
|
||||
use App\Models\Package;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use App\Models\Package;
|
||||
|
||||
class PackageResource extends Resource
|
||||
{
|
||||
@@ -24,6 +22,16 @@ class PackageResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedShoppingCart;
|
||||
|
||||
public static function getModelLabel(): string
|
||||
{
|
||||
return Package::getAttributeLabel('package');
|
||||
}
|
||||
|
||||
public static function getPluralModelLabel(): string
|
||||
{
|
||||
return Package::getAttributeLabel('packages');
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return PackageForm::configure($schema);
|
||||
|
||||
@@ -22,6 +22,16 @@ class ServiceResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPuzzlePiece;
|
||||
|
||||
public static function getModelLabel(): string
|
||||
{
|
||||
return Service::getAttributeLabel('service');
|
||||
}
|
||||
|
||||
public static function getPluralModelLabel(): string
|
||||
{
|
||||
return Service::getAttributeLabel('services');
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ServiceForm::configure($schema);
|
||||
|
||||
@@ -6,7 +6,6 @@ use App\Models\Service;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
@@ -24,8 +23,8 @@ class ServicesTable
|
||||
->label(Service::getAttributeLabel('identifier'))
|
||||
->searchable(),
|
||||
IconColumn::make('icon')
|
||||
->label('Icône')
|
||||
->icon(fn (Service $record) => 'heroicon-o-' . $record->icon),
|
||||
->label(Service::getAttributeLabel('icon'))
|
||||
->icon(fn (Service $record) => 'heroicon-o-'.$record->icon),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
|
||||
@@ -3,9 +3,44 @@
|
||||
namespace App\Filament\Resources\Users\Pages;
|
||||
|
||||
use App\Filament\Resources\Users\UserResource;
|
||||
use App\Models\User;
|
||||
use App\Notifications\AdminInvitationNotification;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateUser extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
/**
|
||||
* Generate a random password if none was provided, so the invitation
|
||||
* flow can proceed without requiring the admin to set one manually.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
if (empty($data['password'])) {
|
||||
$data['password'] = Str::random(32);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an invitation email after the user is created so they can
|
||||
* set their own password via the admin panel reset flow.
|
||||
*/
|
||||
protected function afterCreate(): void
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $this->record;
|
||||
$token = Password::broker()->createToken($user);
|
||||
|
||||
$user->notify(new AdminInvitationNotification($token));
|
||||
Log::info('User invited: '.$user->email);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ class UserForm
|
||||
->required(),
|
||||
TextInput::make('email')
|
||||
->label(User::getAttributeLabel('email'))
|
||||
->label('Email address')
|
||||
->email()
|
||||
->required(),
|
||||
DateTimePicker::make('email_verified_at')
|
||||
@@ -28,14 +27,19 @@ class UserForm
|
||||
TextInput::make('password')
|
||||
->label(User::getAttributeLabel('password'))
|
||||
->password()
|
||||
->revealable()
|
||||
->dehydrated(fn ($state) => filled($state))
|
||||
->dehydrateStateUsing(fn ($state) => Hash::make($state)),
|
||||
->dehydrateStateUsing(fn ($state) => Hash::make($state))
|
||||
->hint(fn (string $operation) => $operation === 'create'
|
||||
? __('users.hints.password_create')
|
||||
: __('users.hints.password_edit'))
|
||||
->hintIcon('heroicon-m-information-circle'),
|
||||
Select::make('role')
|
||||
->label(User::getAttributeLabel('role'))
|
||||
->relationship('roles', 'name')
|
||||
->multiple()
|
||||
->preload()
|
||||
->searchable()
|
||||
->searchable(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Users\Tables;
|
||||
|
||||
use App\Models\User;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
@@ -15,11 +16,13 @@ class UsersTable
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label(User::getAttributeLabel('name'))
|
||||
->searchable(),
|
||||
TextColumn::make('email')
|
||||
->label('Email address')
|
||||
->label(User::getAttributeLabel('email'))
|
||||
->searchable(),
|
||||
TextColumn::make('email_verified_at')
|
||||
->label(User::getAttributeLabel('email_verified_at'))
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
|
||||
@@ -3,14 +3,15 @@
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use App\Notifications\AdminPasswordResetNotification;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Filament\Panel;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Filament\Panel;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
@@ -29,6 +30,7 @@ use Filament\Panel;
|
||||
* @property-read int|null $permissions_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Spatie\Permission\Models\Role> $roles
|
||||
* @property-read int|null $roles_count
|
||||
*
|
||||
* @method static \Database\Factories\UserFactory factory($count = null, $state = [])
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|User newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|User newQuery()
|
||||
@@ -45,11 +47,12 @@ use Filament\Panel;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|User whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|User withoutPermission($permissions)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|User withoutRole($roles, $guard = null)
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class User extends Authenticatable implements FilamentUser
|
||||
{
|
||||
use HasRoles, HasFactory, Notifiable, TwoFactorAuthenticatable;
|
||||
use HasFactory, HasRoles, Notifiable, TwoFactorAuthenticatable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
@@ -87,12 +90,11 @@ class User extends Authenticatable implements FilamentUser
|
||||
|
||||
public function canAccessPanel(Panel $panel): bool
|
||||
{
|
||||
//return str_ends_with($this->email, '@yourdomain.com') && $this->hasVerifiedEmail();
|
||||
//@todo : restreindre aux adresses retzien.fr pour la prod
|
||||
// return str_ends_with($this->email, '@yourdomain.com') && $this->hasVerifiedEmail();
|
||||
// @todo : restreindre aux adresses retzien.fr pour la prod
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static function getAttributeLabel(string $attribute): string
|
||||
{
|
||||
return __("users.fields.$attribute");
|
||||
@@ -103,6 +105,10 @@ class User extends Authenticatable implements FilamentUser
|
||||
return __("roles.fields.' . $role");
|
||||
}*/
|
||||
|
||||
public function sendPasswordResetNotification($token): void
|
||||
{
|
||||
$this->notify(new AdminPasswordResetNotification($token));
|
||||
}
|
||||
|
||||
public function members(): hasMany
|
||||
{
|
||||
|
||||
44
app/Notifications/AdminInvitationNotification.php
Normal file
44
app/Notifications/AdminInvitationNotification.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\NotificationTemplate;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class AdminInvitationNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(protected string $token) {}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$template = NotificationTemplate::findByIdentifier('admin_invitation');
|
||||
$url = Filament::getPanel('admin')->getResetPasswordUrl($this->token, $notifiable);
|
||||
|
||||
$vars = [
|
||||
'name' => $notifiable->name,
|
||||
'url' => $url,
|
||||
'app_name' => config('app.name'),
|
||||
'expire_minutes' => config('auth.passwords.users.expire'),
|
||||
];
|
||||
|
||||
return (new MailMessage)
|
||||
->subject($template->renderSubject($vars))
|
||||
->view('notifications.mail-template', [
|
||||
'body' => $template->renderBody($vars),
|
||||
]);
|
||||
}
|
||||
}
|
||||
44
app/Notifications/AdminPasswordResetNotification.php
Normal file
44
app/Notifications/AdminPasswordResetNotification.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\NotificationTemplate;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class AdminPasswordResetNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(protected string $token) {}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$template = NotificationTemplate::findByIdentifier('admin_password_reset');
|
||||
$url = Filament::getPanel('admin')->getResetPasswordUrl($this->token, $notifiable);
|
||||
|
||||
$vars = [
|
||||
'name' => $notifiable->name,
|
||||
'url' => $url,
|
||||
'app_name' => config('app.name'),
|
||||
'expire_minutes' => config('auth.passwords.users.expire'),
|
||||
];
|
||||
|
||||
return (new MailMessage)
|
||||
->subject($template->renderSubject($vars))
|
||||
->view('notifications.mail-template', [
|
||||
'body' => $template->renderBody($vars),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use Andreia\FilamentNordTheme\FilamentNordThemePlugin;
|
||||
use BezhanSalleh\FilamentShield\FilamentShieldPlugin;
|
||||
use App\Filament\Resources\Members\Widgets\MemberCount;
|
||||
use App\Filament\Resources\Memberships\Widgets\MembershipsChart;
|
||||
use BezhanSalleh\FilamentShield\FilamentShieldPlugin;
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\AuthenticateSession;
|
||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
@@ -33,6 +33,8 @@ class AdminPanelProvider extends PanelProvider
|
||||
->id('admin')
|
||||
->path('admin')
|
||||
->login()
|
||||
->passwordReset()
|
||||
->profile(isSimple: false)
|
||||
->colors([
|
||||
'primary' => Color::Rose,
|
||||
])
|
||||
@@ -46,7 +48,7 @@ class AdminPanelProvider extends PanelProvider
|
||||
AccountWidget::class,
|
||||
FilamentInfoWidget::class,
|
||||
MemberCount::class,
|
||||
//MembershipsChart::class,
|
||||
// MembershipsChart::class,
|
||||
])
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
|
||||
222
app/Services/ListMonk/ListMonkService.php
Normal file
222
app/Services/ListMonk/ListMonkService.php
Normal file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\ListMonk;
|
||||
|
||||
use Illuminate\Http\Client\ConnectionException;
|
||||
use Illuminate\Http\Client\PendingRequest;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class ListMonkService
|
||||
{
|
||||
protected PendingRequest $http;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->http = Http::withBasicAuth(
|
||||
config('services.listmonk.username'),
|
||||
config('services.listmonk.password')
|
||||
)
|
||||
->withHeaders(['Accept' => 'application/json'])
|
||||
->baseUrl(config('services.listmonk.base_url').'/api');
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Lists
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Retrieve all mailing lists.
|
||||
*
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function getLists(): array
|
||||
{
|
||||
return $this->http
|
||||
->get('/lists', ['per_page' => 'all'])
|
||||
->json('data.results') ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single list by its ID.
|
||||
*
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function getList(int $listId): ?array
|
||||
{
|
||||
$response = $this->http->get("/lists/{$listId}");
|
||||
|
||||
if (! $response->successful()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $response->json('data');
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Subscribers
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Retrieve subscribers with optional pagination.
|
||||
*
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function getSubscribers(int $page = 1, int $perPage = 100): array
|
||||
{
|
||||
return $this->http
|
||||
->get('/subscribers', [
|
||||
'page' => $page,
|
||||
'per_page' => $perPage,
|
||||
])
|
||||
->json('data.results') ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single subscriber by their Listmonk ID.
|
||||
*
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function getSubscriber(int $subscriberId): ?array
|
||||
{
|
||||
$response = $this->http->get("/subscribers/{$subscriberId}");
|
||||
|
||||
if (! $response->successful()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $response->json('data');
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a subscriber by their email address.
|
||||
*
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function getSubscriberByEmail(string $email): ?array
|
||||
{
|
||||
$results = $this->http
|
||||
->get('/subscribers', ['query' => "subscribers.email = '{$email}'"])
|
||||
->json('data.results') ?? [];
|
||||
|
||||
return $results[0] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new subscriber and enrol them in the given lists.
|
||||
*
|
||||
* @param array<int> $listIds IDs of the lists to subscribe to.
|
||||
* @param array<string, mixed> $attribs Custom attributes (e.g. language preference).
|
||||
*
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function createSubscriber(
|
||||
string $email,
|
||||
string $name,
|
||||
array $listIds = [],
|
||||
array $attribs = [],
|
||||
string $status = 'enabled',
|
||||
): ?array {
|
||||
$response = $this->http->post('/subscribers', [
|
||||
'email' => $email,
|
||||
'name' => $name,
|
||||
'status' => $status,
|
||||
'lists' => $listIds,
|
||||
'attribs' => $attribs,
|
||||
]);
|
||||
|
||||
if (! $response->successful()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $response->json('data');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing subscriber's information.
|
||||
*
|
||||
* @param array<int> $listIds
|
||||
* @param array<string, mixed> $attribs
|
||||
*
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function updateSubscriber(
|
||||
int $subscriberId,
|
||||
string $email,
|
||||
string $name,
|
||||
array $listIds = [],
|
||||
array $attribs = [],
|
||||
string $status = 'enabled',
|
||||
): bool {
|
||||
$response = $this->http->put("/subscribers/{$subscriberId}", [
|
||||
'email' => $email,
|
||||
'name' => $name,
|
||||
'status' => $status,
|
||||
'lists' => $listIds,
|
||||
'attribs' => $attribs,
|
||||
]);
|
||||
|
||||
return $response->successful();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe or unsubscribe a set of subscribers from lists.
|
||||
*
|
||||
* @param array<int> $subscriberIds
|
||||
* @param array<int> $listIds
|
||||
* @param string $action subscribe | unsubscribe
|
||||
* @param string $status confirmed | unconfirmed
|
||||
*
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function updateSubscriberLists(
|
||||
array $subscriberIds,
|
||||
array $listIds,
|
||||
string $action = 'subscribe',
|
||||
string $status = 'confirmed',
|
||||
): bool {
|
||||
$response = $this->http->put('/subscribers/lists', [
|
||||
'ids' => $subscriberIds,
|
||||
'action' => $action,
|
||||
'status' => $status,
|
||||
'list_ids' => $listIds,
|
||||
]);
|
||||
|
||||
return $response->successful();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a subscriber to the blocklist.
|
||||
*
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function blocklistSubscriber(int $subscriberId): bool
|
||||
{
|
||||
return $this->http
|
||||
->put("/subscribers/{$subscriberId}/blocklist")
|
||||
->successful();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanently delete a subscriber.
|
||||
*
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function deleteSubscriber(int $subscriberId): bool
|
||||
{
|
||||
return $this->http
|
||||
->delete("/subscribers/{$subscriberId}")
|
||||
->successful();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an opt-in confirmation email to a subscriber.
|
||||
*
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function sendOptin(int $subscriberId): bool
|
||||
{
|
||||
return $this->http
|
||||
->post("/subscribers/{$subscriberId}/optin")
|
||||
->successful();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user