2a15449d6432f9a07580472cc8ad14cb22f8016a
[kivitendo-erp.git] / SL / DB / AuthUser.pm
1 # This file has been auto-generated only because it didn't exist.
2 # Feel free to modify it at will; it will not be overwritten automatically.
3
4 package SL::DB::AuthUser;
5
6 use strict;
7
8 use List::Util qw(first);
9
10 use SL::DB::MetaSetup::AuthUser;
11 use SL::DB::AuthUserGroup;
12
13 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
14 __PACKAGE__->meta->make_manager_class;
15
16 __PACKAGE__->meta->schema('auth');
17
18 __PACKAGE__->meta->add_relationship(
19   groups => {
20     type      => 'many to many',
21     map_class => 'SL::DB::AuthUserGroup',
22     map_from  => 'user',
23     map_to    => 'group',
24   },
25   configs => {
26     type       => 'one to many',
27     class      => 'SL::DB::AuthUserConfig',
28     column_map => { id => 'user_id' },
29   },
30 );
31
32 __PACKAGE__->meta->initialize;
33
34 sub get_config_value {
35   my ($self, $key) = @_;
36
37   my $cfg = first { $_->cfg_key eq $key } @{ $self->configs };
38   return $cfg ? $cfg->cfg_value : undef;
39 }
40
41 1;