parent
e0ca5cf7d2
commit
3daadc6194
@ -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…
Reference in new issue