-
-
Save chrisdpeters/1895083 to your computer and use it in GitHub Desktop.
Single Table Inheritance & Nested Properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfcomponent extends="Model" output="false"> | |
<cfset this.modelName = ListLast(GetMetaData(this).name, ".")> | |
<cffunction name="init"> | |
<cfset table(name="calls")> | |
<!--- Validations ---> | |
<cfset validatesPresenceOf(properties="callStatusId") /> | |
<!--- Associations ---> | |
<cfset hasMany(name="taggings", dependent="deleteAll", shortcut="tags", foreignKey="callId") /> | |
<cfset nestedProperties(associations="callNotes,taggings", allowDelete=true) /> | |
</cffunction> | |
</cfcomponent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfcomponent extends="Call" output="false"> | |
<cfset this.modelName = ListLast(GetMetaData(this).name, ".")> | |
<cffunction name="init"> | |
<cfset super.init()> | |
<!--- Validations ---> | |
<cfset validatesPresenceOf(properties="patientname") /> | |
</cffunction> | |
</cfcomponent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfcomponent extends="Model" output="false"> | |
<cffunction name="init"> | |
<!--- Validations ---> | |
<cfset validatesPresenceOf(properties="name")> | |
<!--- Associations ---> | |
<cfset hasMany(name="taggings", shortcut="calls") /> | |
</cffunction> | |
</cfcomponent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfcomponent extends="Model" output="false"> | |
<cffunction name="init"> | |
<!--- Associations ---> | |
<cfset belongsTo(name="call") /> | |
<cfset belongsTo("tag") /> | |
<cfset belongsTo(name="requisitionCall", foreignKey="callId") /> | |
</cffunction> | |
</cfcomponent> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment