Skip to content

Instantly share code, notes, and snippets.

@chrisdpeters
Forked from tdm00/Call.cfc
Created February 23, 2012 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdpeters/1895083 to your computer and use it in GitHub Desktop.
Save chrisdpeters/1895083 to your computer and use it in GitHub Desktop.
Single Table Inheritance & Nested Properties
<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>
<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>
<cfcomponent extends="Model" output="false">
<cffunction name="init">
<!--- Validations --->
<cfset validatesPresenceOf(properties="name")>
<!--- Associations --->
<cfset hasMany(name="taggings", shortcut="calls") />
</cffunction>
</cfcomponent>
<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