Field Manual PHP / Laravel reference
← Engineering

Entity modelling

Entities have stable identity through changing attributes.

What it is

Entities have stable identity through changing attributes.

When to use it

Separate persistent entities from value objects and DTOs.

Syntax

User 1 -> many Accounts
Account 1 -> many Transactions

Example

User: id, email
Account: id, user_id, currency
Transaction: id, account_id, amount_cents, status, external_reference
Money value: amount_cents + currency

Common mistakes

Do not use mutable email as an entity ID; distinguish an account from its balance value.

Related topics

Browse Engineering