Skip to main content

Build a model

A model describes an entity's data and behavior. Start with its identity and fields, then add relationships, actions, and access rules.

Define identity and fields​

Follow Defining Models to choose a base class, declare a primary key, and describe fields and validation. For a first walkthrough, use My First Model.

Connect models​

Use Relationships for references, collections, and join models. Choose the relationship that represents your domain before deciding how a client will navigate it.

Implement behavior and permissions​

Put entity-specific operations in actions, and define who can execute them with permissions. Share capabilities between model classes using behaviors.

Handle persistence and lifecycle​

The model lifecycle explains hooks around creation, updates, and deletion. Repositories connect models to storage implementations.

Expose and test the model​

Choose the interfaces your clients need, then test both domain behavior and permissions. The blog tutorial combines these steps in a complete application.