NAME

Mojolicious::Plugin::Fondation::Group - Group management plugin for Fondation

VERSION

version 0.02

SYNOPSIS

# myapp.conf
{
    'Fondation' => {
        dependencies => [
            'Fondation::User',
            'Fondation::Group',
        ],
    },
}

DESCRIPTION

Mojolicious::Plugin::Fondation::Group provides group management: the groups and user_group (pivot) tables, REST controllers, and automatic many-to-many relations with users and permissions.

Many-to-many relations

When Fondation::User is loaded, group↔user links are established automatically in fondation_finalyze via DBIx::Class::Relationship::ManyToMany::Async.

Similarly, when Fondation::Perm is loaded, group↔perm links are created in that plugin's fondation_finalyze.

with() — many_to_many prefetch

# Include perms (or users) in list/read responses
GET /api/Group?with=perms
GET /api/User?with=groups

# Programmatically:
$c->model('group')->with('perms')->TO_JSON->then(sub ($data) {
    $self->render(openapi => $data);
});
$c->model('user')->with('groups')->TO_JSON->then(sub ($data) {
    $self->render(openapi => $data);
});

with() triggers a single-query prefetch via the pivot table. Target objects are auto-included in the TO_JSON output by Mojolicious::Plugin::Fondation::Schema::Result::Base.

Without with(), m2m relationships are silently excluded.

Controller

REST endpoints (routes generated by OpenAPI):

GET    /api/Group           list all groups
POST   /api/Group           create a group
GET    /api/Group/:id       read a group
PUT    /api/Group/:id       update a group
DELETE /api/Group/:id       delete a group

GET    /api/Group/:id/members      list members
POST   /api/Group/:id/members      add a member
DELETE /api/Group/:id/members/:uid remove a member

SEE ALSO

AUTHOR

Daniel Brosseau <dab@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Daniel Brosseau.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.