SlideShare une entreprise Scribd logo
1  sur  18
The Mystery In The Models
Adding a Model to Your EE Add-on
Current Pittsburgher
I lead tripleNERDscore
I build in EE
I love my fam
I drink more coffee than I should
I’m here to serve!
Models Made Me Wanna….
What Are Models
And
What Do They Do?
How EE Uses Models
Create an Entry
system/ee/EllisLab/ExpressionEngine/Controller/Publish/Publish.php
Read a Member
system/ee/EllisLab/ExpressionEngine/Controller/Members/Members.php
Get a File and Filter on Relationship
system/ee/EllisLab/ExpressionEngine/Controller/Files/Files.php
Let’s Build!
Create Our Data Structure
Data Structure
Model: Vote
Table: upvotedownvote_votes
id - our primary key
entry_id - Associated entry
upvotes - Count of upvotes
downvotes - Count of upvotes
Initiate Our Model
Initiate Our Model
Scaffold Our Model
Let's Make it CRUDdy
What Else Can Models Do?
Relationships
Events
Validation
Metadata
Many to Many Relationships
Collections
Helpful Links:
https://docs.expressionengine.com/latest/development/services/model.html
https://codeigniter.com/userguide3/database/forge.html
https://github.com/dougblackjr/eeconf-presentation
https://github.com/dougblackjr/upvotedownvote
My Stuff
https://triplenerdscore.net
https://ee-addon-generator.triplenerdscore.xyz
twitter: @dougblackjr
Questions?

Contenu connexe

Similaire à The Mystery In The Models: The Basics of Adding a Model to your EE Add-on

Online Testing Learning to Rank with Solr Interleaving
Online Testing Learning to Rank with Solr InterleavingOnline Testing Learning to Rank with Solr Interleaving
Online Testing Learning to Rank with Solr InterleavingSease
 
SharePoint Lists: Used, Abused and Underappreciated
SharePoint Lists: Used, Abused and UnderappreciatedSharePoint Lists: Used, Abused and Underappreciated
SharePoint Lists: Used, Abused and UnderappreciatedWes Preston
 
Building Forio Web Simulations - Introduction to Interface Design
Building Forio Web Simulations - Introduction to Interface DesignBuilding Forio Web Simulations - Introduction to Interface Design
Building Forio Web Simulations - Introduction to Interface Designforiocorp
 
ASAE Tech: Data Data Everywhere
ASAE Tech: Data Data EverywhereASAE Tech: Data Data Everywhere
ASAE Tech: Data Data Everywheremjgoldsmith
 
Get a Little Help with Your Help Desk Application
Get a Little Help with Your Help Desk ApplicationGet a Little Help with Your Help Desk Application
Get a Little Help with Your Help Desk ApplicationIron Speed
 
Essay Writing Service Reviews Top 10 Best Pap
Essay Writing Service Reviews Top 10 Best PapEssay Writing Service Reviews Top 10 Best Pap
Essay Writing Service Reviews Top 10 Best PapAmber Wheeler
 
Office 365 Productivity Tips "May Mediation"
Office 365 Productivity Tips "May Mediation"Office 365 Productivity Tips "May Mediation"
Office 365 Productivity Tips "May Mediation"Christian Buckley
 
Ruby on Rails Plugins - Rich Collins
Ruby on Rails Plugins - Rich CollinsRuby on Rails Plugins - Rich Collins
Ruby on Rails Plugins - Rich CollinsRich Collins
 
Cyber Threats and Data Privacy in a Digital World
Cyber Threats and Data Privacy in a Digital WorldCyber Threats and Data Privacy in a Digital World
Cyber Threats and Data Privacy in a Digital Worldqubanewmedia
 
Improving Spreadsheet Test Practices
Improving Spreadsheet Test PracticesImproving Spreadsheet Test Practices
Improving Spreadsheet Test PracticesFelienne Hermans
 
JDO 2019: Data Science for Developers - Matthew Renze
JDO 2019: Data Science for Developers -  Matthew RenzeJDO 2019: Data Science for Developers -  Matthew Renze
JDO 2019: Data Science for Developers - Matthew RenzePROIDEA
 
How to design with science: and not destroy the magic (Joe Leech)
How to design with science: and not destroy the magic (Joe Leech)How to design with science: and not destroy the magic (Joe Leech)
How to design with science: and not destroy the magic (Joe Leech)Future Insights
 
How to design with science and not destroy the magic
How to design with science and not destroy the magicHow to design with science and not destroy the magic
How to design with science and not destroy the magicJoe Leech
 
Sydney Salesforce NFP user group july 2011
Sydney Salesforce NFP user group july 2011Sydney Salesforce NFP user group july 2011
Sydney Salesforce NFP user group july 2011Kevin Akermanis
 
Data Data Everywhere: Drowning in a Sea of Analytics
Data Data Everywhere: Drowning in a Sea of AnalyticsData Data Everywhere: Drowning in a Sea of Analytics
Data Data Everywhere: Drowning in a Sea of AnalyticsMegan Denhardt
 

Similaire à The Mystery In The Models: The Basics of Adding a Model to your EE Add-on (20)

Online Testing Learning to Rank with Solr Interleaving
Online Testing Learning to Rank with Solr InterleavingOnline Testing Learning to Rank with Solr Interleaving
Online Testing Learning to Rank with Solr Interleaving
 
SharePoint Lists: Used, Abused and Underappreciated
SharePoint Lists: Used, Abused and UnderappreciatedSharePoint Lists: Used, Abused and Underappreciated
SharePoint Lists: Used, Abused and Underappreciated
 
Building Forio Web Simulations - Introduction to Interface Design
Building Forio Web Simulations - Introduction to Interface DesignBuilding Forio Web Simulations - Introduction to Interface Design
Building Forio Web Simulations - Introduction to Interface Design
 
ASAE Tech: Data Data Everywhere
ASAE Tech: Data Data EverywhereASAE Tech: Data Data Everywhere
ASAE Tech: Data Data Everywhere
 
Get a Little Help with Your Help Desk Application
Get a Little Help with Your Help Desk ApplicationGet a Little Help with Your Help Desk Application
Get a Little Help with Your Help Desk Application
 
Essay Writing Service Reviews Top 10 Best Pap
Essay Writing Service Reviews Top 10 Best PapEssay Writing Service Reviews Top 10 Best Pap
Essay Writing Service Reviews Top 10 Best Pap
 
Trigger Emails BigD17
Trigger Emails BigD17Trigger Emails BigD17
Trigger Emails BigD17
 
Pratical Deep Dive into the Semantic Web - #smconnect
Pratical Deep Dive into the Semantic Web - #smconnectPratical Deep Dive into the Semantic Web - #smconnect
Pratical Deep Dive into the Semantic Web - #smconnect
 
Office 365 Productivity Tips "May Mediation"
Office 365 Productivity Tips "May Mediation"Office 365 Productivity Tips "May Mediation"
Office 365 Productivity Tips "May Mediation"
 
Ignite pitch
Ignite pitchIgnite pitch
Ignite pitch
 
Mis 1 Chapter
Mis 1 ChapterMis 1 Chapter
Mis 1 Chapter
 
Ruby on Rails Plugins - Rich Collins
Ruby on Rails Plugins - Rich CollinsRuby on Rails Plugins - Rich Collins
Ruby on Rails Plugins - Rich Collins
 
Cyber Threats and Data Privacy in a Digital World
Cyber Threats and Data Privacy in a Digital WorldCyber Threats and Data Privacy in a Digital World
Cyber Threats and Data Privacy in a Digital World
 
Improving Spreadsheet Test Practices
Improving Spreadsheet Test PracticesImproving Spreadsheet Test Practices
Improving Spreadsheet Test Practices
 
JDO 2019: Data Science for Developers - Matthew Renze
JDO 2019: Data Science for Developers -  Matthew RenzeJDO 2019: Data Science for Developers -  Matthew Renze
JDO 2019: Data Science for Developers - Matthew Renze
 
How to design with science: and not destroy the magic (Joe Leech)
How to design with science: and not destroy the magic (Joe Leech)How to design with science: and not destroy the magic (Joe Leech)
How to design with science: and not destroy the magic (Joe Leech)
 
How to design with science and not destroy the magic
How to design with science and not destroy the magicHow to design with science and not destroy the magic
How to design with science and not destroy the magic
 
Sydney Salesforce NFP user group july 2011
Sydney Salesforce NFP user group july 2011Sydney Salesforce NFP user group july 2011
Sydney Salesforce NFP user group july 2011
 
Becoming a Power User
Becoming a Power UserBecoming a Power User
Becoming a Power User
 
Data Data Everywhere: Drowning in a Sea of Analytics
Data Data Everywhere: Drowning in a Sea of AnalyticsData Data Everywhere: Drowning in a Sea of Analytics
Data Data Everywhere: Drowning in a Sea of Analytics
 

Dernier

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Dernier (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

The Mystery In The Models: The Basics of Adding a Model to your EE Add-on

Notes de l'éditeur

  1. A model is class that represents a logical structure and associated database table. In other words, models manage data. EE has a number of models already there, like Channel, ChannelEntry, Member, Template, etc.
  2. - Create an Entry system/ee/EllisLab/ExpressionEngine/Controller/Publish/Publish.php - Read a Member system/ee/EllisLab/ExpressionEngine/Controller/Members/Members.php - Get a File with Relationship system/ee/EllisLab/ExpressionEngine/Controller/Files/Files.php
  3. Let’s help E720 change their site so people can upvote and downvote their content
  4. ### Create our Data and DB Tables - Models don't create your database tables by default, so we'll need to use the DBForge to create them. 1. Map our data first 2. Create schema in `upd` file
  5. ### Create our Data and DB Tables - Models don't create your database tables by default, so we'll need to use the DBForge to create them. 1. Map our data first 2. Create schema in `upd` file
  6. ### Initiate Our Model Models are registerd in your addon.setup.php file Add it to your add-on setup 1. `models` array 2. Lots of ways to extend this, we'll go through one way later
  7. ### Initiate Our Model Models are registerd in your addon.setup.php file Add it to your add-on setup 1. `models` array 2. Lots of ways to extend this, we'll go through one way later
  8. ### Scaffolding - Let's look at the basics of the model 1. Extend the EE Model class 2. Primary Key and Table Name are required 3. Protected Elements of the Model are your data points
  9. ### Let's Make it CRUDdy! 1. `votes` method: Reading the votes, Creating a new one 2. `cast_vote` method: Updating the votes
  10. ### Relationships - By nature of our Votes model, it's connected to a ChannelEntry. - Only problem is that we have not defined this relationship, so we would need multiple DB calls to get it. - Relationships relate entries 1. Define the relationship 2. Define the inverse (addon.setup and Vote model) 3. `top` method: Getting entries by the top voted ## What Else Can Models Do? - Events (i.e. update another model when your model is updated) - Validation (i.e. check to make sure data coming in is good and will save) - Metadata (i.e. setting variables re: whether model was updated) - Relationships with pivot tables (i.e. tagging entries, multiple entries can have multiple tags) - Collections (manage multiple items in your data)