[Dbix-class] Subclass a Result class.

Matt S Trout mst at shadowcat.co.uk
Thu Apr 29 20:52:56 GMT 2010


On Thu, Apr 29, 2010 at 12:49:30PM -0700, Bill Moseley wrote:
> On Wed, Apr 28, 2010 at 7:27 AM, Matt S Trout <mst at shadowcat.co.uk> wrote:
> 
> > > For that to happen the $session_attendee needs to be specific to a given
> > > session (Session id is stored with the $session_attendee instance).
> >
> > You just answered your own question.
> >
> > You want a result from the many-many link table and to traverse from there,
> > since that table has (session_id, attendee_id).
> >
> 
> That seems to reason, yes.  Sadly, I'm not seeing the implementation so I
> ask for a bit more help.
> 
> Again, what I'm after is:
> 
> $session_one = $schema->resultset( 'Session' )->find( 1 );
> 
> $session_one_attendees = $session_one->attendees;
> $first_user_session_one_notes = $session_one_attendees->first->notes;

Again, no it isn't.

You need to expose the link entry directly and add relationships to it,
and you need to add methods to *there* - proxy => on the belongs_to across to
Attendee will let you proxy the Attendee things.

Then you end up with an object that you can -treat- as an Attendee but
is actually an AttendeeWithSession - i.e. a SessionAttendee - i.e. a member
of the many-many link class.

-- 
Matt S Trout - Shadowcat Systems - Perl consulting with a commit bit and a clue

http://shadowcat.co.uk/blog/matt-s-trout/   http://twitter.com/shadowcat_mst/

Email me now on mst (at) shadowcat.co.uk and let's chat about how our Catalyst
commercial support, training and consultancy packages could help your team.



More information about the DBIx-Class mailing list