@tdtank59
How I’m doing it requires a little reversal of thought. Instead of using a join table, use a dedicated model for the join, with two one-to-N relationships. Then you can include whatever information you want in that table.
It isn’t seamless yet, but I’m too busy to worry about making it better. You can still perform some very slick queries, though:
// relationship: user <- vote -> song
// get all votes and usernames for a song
$song->vote->join_related("user", array("name"))->get();
foreach($song->vote as $v) {
echo($v->user_name . ": " . $v->rating);
}
// get all votes for this user
$user->vote->join_related("song", array("title", "artist"))->get();
// get all voting users for this song
$user = new User();
// this will lookup the users themselves, based on $song
$user->where_related("vote", "song_id", $song->id);
// Same as above, but add in the rating. Note: this is a where the "hack" comes in
$user->where_related("vote", "song_id", $song->id);
$user->select("votes.rating as vote_rating");
$user->get(); // this is now similar to the first query, but using the User model.