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" }, { cascade_copy => 0, cascade_delete => 0 }, ); __PACKAGE__->belongs_to( "group", "NGCP::Schema::Result::provisioning_voip_subscribers", { "foreign.id" => "self.group_id" }, { cascade_copy => 0, cascade_delete => 0 }, ); __PACKAGE__->has_many( "groups", "NGCP::Schema::Result::provisioning_voip_subscribers", { "foreign.id" => "self.group_id" }, { cascade_copy => 0, cascade_delete => 0 }, ); __PACKAGE__->has_many( "subscribers", "NGCP::Schema::Result::provisioning_voip_subscribers", { "foreign.id" => "self.subscriber_id" }, { cascade_copy => 0, cascade_delete => 0 }, ); sub TO_JSON { my ($self) = @_; return { map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method } }; } 1;