epic-s6ts
[kivitendo-erp.git] / SL / DB / Employee.pm
1 package SL::DB::Employee;
2
3 use strict;
4
5 use SL::DB::MetaSetup::Employee;
6 use SL::DB::Manager::Employee;
7
8 __PACKAGE__->meta->add_relationship(
9   project_invoice_permissions  => {
10     type       => 'many to many',
11     map_class  => 'SL::DB::EmployeeProjectInvoices',
12   },
13 );
14
15 __PACKAGE__->meta->initialize;
16
17 sub has_right {
18   my $self  = shift;
19   my $right = shift;
20
21   return $::auth->check_right($self->login, $right);
22 }
23
24 sub safe_name {
25   my ($self) = @_;
26
27   return $self->name || $self->login;
28 }
29
30 sub auth_user {
31   my ($self) = @_;
32
33   die 'not an accessor' if scalar(@_) > 1;
34
35   require SL::DB::AuthUser;
36
37   return SL::DB::Manager::AuthUser->find_by(login => $self->login);
38 }
39
40 1;