Re: [Dbix-class] has_one over joining table

2018-01-30 Thread Andrew Beverley
On Tue, 30 Jan 2018 09:42:26 +0100 Stuart Dodds wrote: > > You would then do something like: > > > > $town->town_people_mayor->mayor > > Hi Andy, > > Yes, that works perfectly...thank you! You're welcome! > It would have been nice to do it in one step as I wouldn't need to > change the

Re: [Dbix-class] has_one over joining table

2018-01-30 Thread Stuart Dodds
On 29/01/18 17:31, Andrew Beverley wrote: > Something like (in Result::Town): > > __PACKAGE__->might_have( > "town_people_mayor", > "MyApp::Schema::Result::TownPeople", > sub { > my $args = shift; > return { > "$args->{foreign_alias}.town_id" => { -ident

Re: [Dbix-class] has_one over joining table

2018-01-29 Thread Andrew Beverley
On Mon, 29 Jan 2018 12:34:14 +0100 Stuart Dodds wrote: > I have a many to many relationship over a joining table, eg. > > towns -> town_people -> people > > In some cases it is possible for there to be has_one relationships > between the two outer tables. It's a bit of a contrived example but

[Dbix-class] has_one over joining table

2018-01-29 Thread Stuart Dodds
Hi, I have a many to many relationship over a joining table, eg. towns -> town_people -> people In some cases it is possible for there to be has_one relationships between the two outer tables. It's a bit of a contrived example but lets say a person can live in multiple towns but only one is her