Hi Could someone point out to me how to properly name the relations in the situation when an ActiveRecord is self-referential. Like this:
A Category can have many sub categories:
CREATE TABLE `categories` (
`category_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`parent_id` int(11) unsigned DEFAULT NULL,
`name` varchar(255) NOT NULL,
`ordinal` smallint(5) unsigned NOT NULL,
PRIMARY KEY (`category_id`),
KEY `parent_id` (`parent_id`),
CONSTRAINT `categories_ibfk_2` FOREIGN KEY (`parent_id`) REFERENCES `categories` (`category_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Buy default you would use the ActiveRecord like this to get parent:
$category->createCategory();
and to get children:
$category->buildCategories();
I want to use parent and children instead, so I have set up the configure() method like this:
fGrammar::addHumanizeRule('Child', 'children');
fORMRelated::overrideRelatedRecordName($this, 'Category', 'Child', 'categories');
fORMRelated::overrideRelatedRecordName($this, 'Category', 'Parent', 'category');
But that seems to have no positive effect. The second line produces this exception:
The route specified, categories, is not a valid route between categories and categories. Must be one of: parent_id.
I set the humanize rule because I'm unsure that flourish will correctly humanize the relation Child using pluralization.
How do I figure out the correct route?