Improvements
Added HABTM annotations for pivot table and its Table class relation.
For BelongsToMany relationships this will add typehinting/clickability for the pivot table and its Table class:
// FeaturesTable
$this->belongsToMany('DependingFeatures', [
'foreignKey' => 'feature_id',
'className' => 'Features',
'targetForeignKey' => 'depending_feature_id',
'joinTable' => 'features_features',
'propertyName' => 'depending_features',
]);
$this->belongsToMany('Modules', [
'foreignKey' => 'feature_id',
'targetForeignKey' => 'module_id',
'through' => 'FeaturesModules',
'joinTable' => 'features_modules',
'propertyName' => 'modules',
]);
now adds
* @property \App\Model\Table\FeaturesFeaturesTable|\Cake\ORM\Association\HasMany $FeaturesFeatures
* @property \App\Model\Table\FeaturesModulesTable|\Cake\ORM\Association\HasMany $FeaturesModules
*/
class FeaturesTable extends Table
or at least basic Cake\ORM\Table class for chaining and querying on the pivot table as in
$this->Features->FeaturesModules->find()->contain(['Modules', 'Features']);
// or
$this->Features->FeaturesFeatures->find()->contain(['DependingFeatures', 'Features']);
Note one time through and one time auto-calculation alias.