1 package Koha::Patron::Relationships;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use List::MoreUtils qw( uniq );
24 use Koha::Patron::Relationship;
26 use base qw(Koha::Objects);
30 Koha::Patron::Relationships - Koha Patron Relationship Object set class
40 Returns all the guarantors in this set of relationships as a list of Koha::Patron objects
41 or as a Koha::Patrons object depending on the calling context
48 my $rs = $self->_resultset();
50 my @guarantor_ids = $rs->get_column('guarantor_id')->all();
51 # Guarantors may not have a guarantor_id, strip out undefs
52 @guarantor_ids = grep { defined $_ } @guarantor_ids;
53 @guarantor_ids = uniq( @guarantor_ids );
55 my $guarantors = Koha::Patrons->search( { borrowernumber => \@guarantor_ids } );
57 return wantarray ? $guarantors->as_list : $guarantors;
62 Returns all the guarantees in this set of relationships as a list of Koha::Patron objects
63 or as a Koha::Patrons object depending on the calling context
70 my $rs = $self->_resultset();
72 my @guarantee_ids = uniq( $rs->get_column('guarantee_id')->all() );
74 my $guarantees = Koha::Patrons->search(
75 { borrowernumber => \@guarantee_ids },
77 order_by => { -asc => [ 'surname', 'firstname' ] }
81 return wantarray ? $guarantees->as_list : $guarantees;
89 return 'BorrowerRelationship';
97 return 'Koha::Patron::Relationship';