Skip to content

Behavioral Traits

lpachecob edited this page Mar 22, 2026 · 6 revisions

🛡️ Behavioral Traits: Pro Attributes

In BOUNDLY, you add enterprise features with a single class attribute. These traits automate horizontal concerns like auditing, deletion, and segmentation.


🛡️ #[Auditable]

Automates traceability for your creation and modification.

Property Default Description
createdBy 'created_by' The column name for the creator.
updatedBy 'updated_by' The column name for the last updater.

How it works:

  1. The DB: core:migrate will add created_by and updated_by as BIGINT columns.
  2. The Logic: On every create() or update(), BOUNDLY will auto-populate these with the auth()->user()->id.
#[Entity(...)]
#[Auditable]
class Product extends AggregateRoot { ... }

🗑️ #[SoftDelete]

Enables logical deletion (doesn't destroy the row).

Property Default Description
deletedAt 'deleted_at' The column name for the deletion timestamp.

How it works:

  1. The DB: core:migrate will add deleted_at as a TIMESTAMP.
  2. The Logic: All GET requests in BOUNDLY's repository will automatically filter where deleted_at IS NULL.
  3. The Action: DELETE requests will set the timestamp instead of executing a DELETE SQL command.
#[Entity(...)]
#[SoftDelete]
class Order extends AggregateRoot { ... }

🏢 #[TenantAware]

Isolates data by "Tenant" code. Essential for SAAS.

Property Default Description
tenantKey 'tenant_id' The column name for the tenant.

How it works:

  1. The DB: core:migrate adds a tenant_id column.
  2. The Logic: BOUNDLY will automatically add a WHERE tenant_id = current_tenant_id() on EVERY select, update, and delete.
  3. The Auth: The common tenant_id is extracted from the authenticated user or the request context.
#[Entity(...)]
#[TenantAware]
class Inventory extends AggregateRoot { ... }

🧪 Combinations

You can combine all of them for a truly enterprise-level entity:

#[Entity(...)]
#[Auditable]
#[SoftDelete]
#[TenantAware]
class Client extends AggregateRoot { ... }

Next Step: Query-Engine 🔎

Clone this wiki locally