Skip to content

Instantly share code, notes, and snippets.

@McGaiser
Last active February 24, 2016 06:27
Show Gist options
  • Save McGaiser/556503d067021fc9f469 to your computer and use it in GitHub Desktop.
Save McGaiser/556503d067021fc9f469 to your computer and use it in GitHub Desktop.
//MembershipClassesTable.php
namespace App\Model\Table;
use Cake\ORM\Table;
use Cake\Validation\Validator;
use Cake\Model\Behavior\TreeBehavior;
class MembershipClassesTable extends AppTable {
public function initialize(array $config){
parent::initialize($config);
$this->displayField('name');
//Associations
$this->belongsTo('Affiliates');
$this->belongsToMany('Roles', [
'through'=>'MembershipClassesRoles',
'join_table'=>'membership_classes_roles',
'foreignKey' => 'membership_class_id',
'targetForeignKey' => 'role_id',
]);
$this->hasMany('PrestigeLogsMembershipClasses', [
'dependant' => true,
'cascadeCallbacks' => true,
'foreignKey' => 'membership_class_id',
]);
}
}
//PrestigeLogsMembershipClasses.php
namespace App\Model\Table;
use Cake\ORM\Table;
use Cake\ORM\RulesChecker;
use Cake\Validation\Validator;
class PrestigeLogsMembershipClassesTable extends AppTable {
public function initialize(array $config){
parent::initialize($config);
$this->belongsTo('PrestigeLogs');
$this->belongsTo('MembershipClasses');
$this->belongsTo('Officers', [
'className' => 'Members',
'foreignKey' => 'officer_id',
]);
}
}
//From the PrestigeLogsController
debug($this->PrestigeLogs->PrestigeLogsMembershipClasses->MembershipClasses);
Table "Cake\ORM\Table" is not associated with "MembershipClasses"
Please try correcting the issue for the following table aliases:
PrestigeLogsMembershipClasses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment