Lines 17-22
package Koha::Patron::Attribute;
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
|
|
20 |
use Koha::Database; |
21 |
use Koha::Exceptions::Patron::Attribute; |
20 |
use Koha::Patron::Attribute::Types; |
22 |
use Koha::Patron::Attribute::Types; |
21 |
|
23 |
|
22 |
use base qw(Koha::Object); |
24 |
use base qw(Koha::Object); |
Lines 31-36
Koha::Patron::Attribute - Koha Patron Attribute Object class
Link Here
|
31 |
|
33 |
|
32 |
=cut |
34 |
=cut |
33 |
|
35 |
|
|
|
36 |
=head3 store |
37 |
|
38 |
my $attribute = Koha::Patron::Attribute->new({ code => 'a_code', ... }); |
39 |
try { $attribute->store } |
40 |
catch { handle_exception }; |
41 |
|
42 |
=cut |
43 |
|
44 |
sub store { |
45 |
|
46 |
my $self = shift; |
47 |
|
48 |
if ( Koha::Patron::Attribute::Types->find( $self->code )->unique_id ) { |
49 |
my $attr_count |
50 |
= Koha::Database->new->schema->resultset( $self->_type )->search( |
51 |
{ borrowernumber => $self->borrowernumber, |
52 |
code => $self->code |
53 |
} |
54 |
)->count; |
55 |
Koha::Exceptions::Patron::Attribute::UniqueIDConstraint->throw() |
56 |
if $attr_count > 0; |
57 |
} |
58 |
|
59 |
return $self->SUPER::store(); |
60 |
} |
61 |
|
34 |
=head3 opac_display |
62 |
=head3 opac_display |
35 |
|
63 |
|
36 |
my $attribute = Koha::Patron::Attribute->new({ code => 'a_code', ... }); |
64 |
my $attribute = Koha::Patron::Attribute->new({ code => 'a_code', ... }); |
37 |
- |
|
|