View | Details | Raw Unified | Return to bug 40275
Collapse All | Expand All

(-)a/Koha/Patrons.pm (-2 / +26 lines)
Lines 37-46 Koha::Patron - Koha Patron Object class Link Here
37
37
38
=head1 API
38
=head1 API
39
39
40
=head2 Class Methods
40
=head2 Class methods
41
41
42
=cut
42
=cut
43
43
44
=head3 find_by_identifier
45
46
    my $patron = Koha::Patrons->find_by_identifier($identifier);
47
48
Find a patron by either userid or cardnumber. Returns the first patron found
49
or undef if no patron matches the identifier.
50
51
This method searches first by userid, then by cardnumber if no match is found.
52
53
=cut
54
55
sub find_by_identifier {
56
    my ( $self, $identifier ) = @_;
57
58
    return unless defined $identifier && $identifier ne '';
59
60
    # First try to find by userid
61
    my $patron = $self->search( { userid => $identifier } )->next;
62
63
    # If not found by userid, try cardnumber
64
    $patron = $self->search( { cardnumber => $identifier } )->next unless $patron;
65
66
    return $patron;
67
}
68
44
=head3 search_limited
69
=head3 search_limited
45
70
46
my $patrons = Koha::Patrons->search_limit( $params, $attributes );
71
my $patrons = Koha::Patrons->search_limit( $params, $attributes );
47
- 

Return to bug 40275