Cole is a multi-tenant platform where every school operates as a fully isolated account called a tenant. Whether you are managing attendance records, agenda entries, or student data, every piece of information belongs to exactly one tenant and is never visible to another. This isolation is enforced at the database query level automatically — no manual filtering is required from controllers or services.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/iamalexis689725/cole/llms.txt
Use this file to discover all available pages before exploring further.
What is a Tenant?
A tenant represents a single school registered in Cole. It is identified by a numericid and a human-readable slug. Every user, teacher, student, and resource created inside the platform belongs to one tenant.
The tenants table stores four key fields:
| Column | Type | Description |
|---|---|---|
id | integer | Auto-incremented primary key |
name | string | Display name of the school |
slug | string | Unique URL-safe identifier |
is_active | boolean | Whether the tenant account is enabled |
Tenant Eloquent model exposes its enabled modules through a belongsToMany relationship that also carries the activo pivot flag:
The BelongsToTenant Trait
The BelongsToTenant trait is the cornerstone of data isolation in Cole. Any Eloquent model that uses this trait receives two automatic behaviours registered in the booted() lifecycle hook.
Auto-assign on create
When a new record is saved, the
creating hook automatically sets tenant_id from the authenticated user. No controller needs to pass it manually.Global query scope
A global Eloquent scope named
tenant appends a WHERE tenant_id = ? clause to every query on the model, using the authenticated user’s tenant_id.Both behaviours are conditional on
auth()->check(). Unauthenticated contexts — such as seeders or console commands — are unaffected and can operate across all tenants freely.TenantMiddleware
The TenantMiddleware runs on every authenticated API route and binds the current user’s tenant_id into Laravel’s IoC container. This makes the tenant context available to any service-layer code that needs it outside of Eloquent models.
Kernel.php under the alias tenant and is applied to protected route groups:
Tenant-Scoped Models
Every model listed below uses theBelongsToTenant trait. All queries against these models are automatically filtered to the authenticated user’s tenant, and all new records are automatically stamped with that tenant’s id.
| Model | Resource description |
|---|---|
AcademicPeriod | Academic year / period definitions |
Agenda | Academic agenda entries |
AgendaArchivo | File attachments on agenda items |
Anecdotario | Teacher anecdotal notes on students |
AsignacionDocente | Teacher-to-course assignments |
Asistencia | Attendance records |
Circular | School circulars / announcements |
Criterio | Grading criteria |
Curso | Courses / subjects |
EntregaTarea | Student task submissions |
EntregaTareaArchivo | Files attached to task submissions |
Estudiante | Student profiles |
HorarioAsignacion | Schedule assignments |
Inscripcion | Course enrolments |
Nota | Student grades |
PadreEstudiante | Parent-to-student relationship records |
PadreFamilia | Parent / guardian profiles |
Paralelo | Class sections / parallels |
PeriodoEvaluacion | Evaluation periods |
Profesor | Teacher profiles |
ProfesorSubject | Teacher-to-subject assignments |
Subject | Subject definitions |
Super-Admin and Cross-Tenant Access
Thesuper-admin role is the only role whose tenant_id is null. The BelongsToTenant global scope fires whenever auth()->check() returns true — which includes super-admins — but because the authenticated user’s tenant_id is null, the appended WHERE tenant_id = NULL clause matches no rows in normal SQL comparison. In practice, super-admin queries should bypass tenant-scoped models entirely and use withoutGlobalScope('tenant') where cross-tenant access is required.
The
CheckModule middleware also short-circuits for super-admin users, granting them access to every module endpoint regardless of a tenant’s module configuration. See Modules for details.Creating a Tenant
Tenants are created by asuper-admin via the Tenants API: