From 2b132512e801b1bb21f151c5eca45a3f6c0dc5da Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 20 Jul 2011 09:53:05 -0700 Subject: [PATCH] Add comment regarding foreign and associated keys in eloquent. --- system/db/eloquent.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system/db/eloquent.php b/system/db/eloquent.php index 6398cfbe..1eea0169 100644 --- a/system/db/eloquent.php +++ b/system/db/eloquent.php @@ -285,6 +285,8 @@ public function has_and_belongs_to_many($model, $table = null, $foreign_key = nu $this->relating_table = $table; } + // Allowing the overriding of the foreign and associated keys provides the flexibility for + // self-referential many-to-many relationships, such as a "buddy list". $this->relating_key = (is_null($foreign_key)) ? strtolower(get_class($this)).'_id' : $foreign_key; $associated_key = (is_null($associated_key)) ? strtolower($model).'_id' : $associated_key;