Team// Post.cfc
component extends="quick.models.BaseEntity" accessors="true" {
function team() {
return belongsToThrough( [ "author", "team" ] );
}
function author() {
return belongsTo( "Post" );
}
}// User.cfc
component extends="quick.models.BaseEntity" accessors="true" {
function posts() {
return hasMany( "Post" );
}
function team() {
return belongsTo( "Team" );
}
}// Team.cfc
component extends="quick.models.BaseEntity" accessors="true" {
function members() {
return hasMany( "User" );
}
}belongsToThrough( [ "author", "team" ] );
+----------------+---------------------------+----------------+
| Current Entity | Relationship Method Names | Related Entity |
+================+===========================+================+
| Post | author | User |
+----------------+---------------------------+----------------+
| User | team | Team |
+----------------+---------------------------+----------------+// Post.cfc
component extends="quick.models.BaseEntity" accessors="true" {
function office() {
return belongsToThrough( [ "author", "team", "office" ] );
}
function author() {
return belongsTo( "Post" );
}
}// User.cfc
component extends="quick.models.BaseEntity" accessors="true" {
function posts() {
return hasMany( "Post" );
}
function team() {
return belongsTo( "Team" );
}
}// Team.cfc
component extends="quick.models.BaseEntity" accessors="true" {
function members() {
return hasMany( "User" );
}
function office() {
return belongsTo( "Office" );
}
}// Office.cfc
component extends="quick.models.BaseEntity" accessors="true" {
function teams() {
return hasMany( "Team" );
}
}belongsToThrough( [ "author", "team", "office" ] );
+----------------+---------------------------+----------------+
| Current Entity | Relationship Method Names | Related Entity |
+================+===========================+================+
| Post | author | User |
+----------------+---------------------------+----------------+
| User | team | Team |
+----------------+---------------------------+----------------+
| Team | office | Office |
+----------------+---------------------------+----------------+// Post.cfc
component extends="quick.models.BaseEntity" accessors="true" {
function team() {
return belongsToThrough( [ "author", "team" ] ).withDefault();
}
function author() {
return belongsTo( "Post" );
}
}// Post.cfc
component extends="quick.models.BaseEntity" accessors="true" {
function team() {
return belongsToThrough( [ "author", "team" ] ).withDefault( {
"name": "No Team"
} );
}
function author() {
return belongsTo( "Post" );
}
}