From: Moritz Bunkus Date: Fri, 26 Nov 2021 16:37:40 +0000 (+0100) Subject: SL::DB::Employee::auth_user: holt korrespondierendes Objekt aus auth.users X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~278 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=c2e1239427e2a7964d8a7f87a06645a1cacaea25;p=kivitendo-erp.git SL::DB::Employee::auth_user: holt korrespondierendes Objekt aus auth.users Convenience-Funktion, um einfacher an Config-Werte heranzukommen. Beispiel: foreach my $employee (@{ SL::DB::Manager::Employee->get_all }) { my $email = $employee->auth_user->get_config_value('email'); do_stuff_with($email); } --- diff --git a/SL/DB/Employee.pm b/SL/DB/Employee.pm index 8da20c0b9..0c321b62f 100644 --- a/SL/DB/Employee.pm +++ b/SL/DB/Employee.pm @@ -27,4 +27,14 @@ sub safe_name { return $self->name || $self->login; } +sub auth_user { + my ($self) = @_; + + die 'not an accessor' if scalar(@_) > 1; + + require SL::DB::AuthUser; + + return SL::DB::Manager::AuthUser->find_by(login => $self->login); +} + 1;