Skip to content

Instantly share code, notes, and snippets.

@commercial-hippie
Forked from McGaiser/gist:556503d067021fc9f469
Last active February 24, 2016 06:29
Show Gist options
  • Save commercial-hippie/a454b232d0d44604fa4e to your computer and use it in GitHub Desktop.
Save commercial-hippie/a454b232d0d44604fa4e to your computer and use it in GitHub Desktop.
<?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',
]);
}
}
<?php
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
<?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',
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment