MT#7545 Allow multiple pbx groups per subscriber

agranig/pbx-dev-map
Andreas Granig 11 years ago
parent e0ca5cf7d2
commit 3daadc6194

@ -37,8 +37,6 @@ __PACKAGE__->add_columns(
{ data_type => "varchar", is_nullable => 1, size => 127 },
"webpassword",
{ data_type => "varchar", is_nullable => 1, size => 40 },
"pbx_group_id",
{ data_type => "integer", extra => { unsigned => 1 }, is_nullable => 1 },
"pbx_hunt_policy",
{
data_type => "enum",
@ -156,10 +154,10 @@ __PACKAGE__->might_have(
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->belongs_to(
"voip_pbx_group",
"NGCP::Schema::Result::voip_subscribers",
{ "foreign.id" => "self.pbx_group_id" },
__PACKAGE__->has_many(
"voip_pbx_groups",
"NGCP::Schema::Result::voip_pbx_groups",
{ "foreign.subscriber_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);

@ -0,0 +1,72 @@
package NGCP::Schema::Result::voip_pbx_groups;
use Scalar::Util qw(blessed);
use parent 'DBIx::Class::Core';
our $VERSION = '2.007';
__PACKAGE__->load_components("Helper::Row::ToJSON");
__PACKAGE__->table("provisioning.voip_pbx_groups");
__PACKAGE__->add_columns(
"id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_auto_increment => 1,
is_nullable => 0,
},
"subscriber_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_foreign_key => 1,
is_nullable => 0,
},
"group_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_foreign_key => 1,
is_nullable => 0,
},
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to(
"subscriber",
"NGCP::Schema::Result::provisioning_voip_subscribers",
{ "foreign.id" => "self.subscriber_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
__PACKAGE__->belongs_to(
"group",
"NGCP::Schema::Result::provisioning_voip_subscribers",
{ "foreign.id" => "self.group_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
__PACKAGE__->has_many(
"groups",
"NGCP::Schema::Result::provisioning_voip_subscribers",
{ "foreign.id" => "self.group_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
__PACKAGE__->has_many(
"subscribers",
"NGCP::Schema::Result::provisioning_voip_subscribers",
{ "foreign.id" => "self.subscriber_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
sub TO_JSON {
my ($self) = @_;
return {
map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method }
};
}
1;
Loading…
Cancel
Save