Added entity postcode lookup

This commit is contained in:
Finn 2019-07-12 21:30:34 +01:00
parent 04a8186b2a
commit 697c1494b0
12 changed files with 4793 additions and 1 deletions

View file

@ -42,6 +42,11 @@ __PACKAGE__->might_have(
"Pear::LocalLoop::Schema::Result::EntityAssociation" => "entity_id",
);
__PACKAGE__->might_have(
"postcode",
"Pear::LocalLoop::Schema::Result::EntityPostcode" => "entity_id",
);
__PACKAGE__->has_many(
"purchases",
"Pear::LocalLoop::Schema::Result::Transaction",

View file

@ -0,0 +1,44 @@
package Pear::LocalLoop::Schema::Result::EntityPostcode;
use strict;
use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->table('entities_postcodes');
__PACKAGE__->add_columns(
outcode => {
data_type => 'char',
size => 4,
is_nullable => 0,
},
incode => {
data_type => 'char',
size => 3,
is_nullable => 0,
},
entity_id => {
data_type => 'integer',
is_nullable => 0,
is_foreign_key => 1,
},
);
__PACKAGE__->set_primary_key(qw/ outcode incode entity_id /);
__PACKAGE__->belongs_to(
"entity",
"Pear::LocalLoop::Schema::Result::Entity",
"entity_id",
);
__PACKAGE__->belongs_to(
"gb_postcode",
"Pear::LocalLoop::Schema::Result::GbPostcode",
{
"foreign.outcode" => "self.outcode",
"foreign.incode" => "self.incode",
},
);
1;