Open-Source Wikis

/

Laravel

/

Reference

/

Data models

laravel/laravel

Data models

Every table the skeleton creates and the model classes (if any) that map to them.

users table

Created by database/migrations/0001_01_01_000000_create_users_table.php. Mapped by App\Models\User (app/Models/User.php).

Columns

Column Type Nullable Default Notes
id bigint (PK) No auto $table->id()
name varchar(255) No
email varchar(255) No Unique index
email_verified_at timestamp Yes NULL
password varchar(255) No Stored as bcrypt hash
remember_token varchar(100) Yes NULL Created via $table->rememberToken()
created_at timestamp Yes NULL Created via $table->timestamps()
updated_at timestamp Yes NULL Created via $table->timestamps()

Eloquent attributes

App\Models\User declares:

#[Fillable(['name', 'email', 'password'])]
#[Hidden(['password', 'remember_token'])]
  • $fillable['name', 'email', 'password'] (only these columns are mass-assignable via User::create([...])).
  • $hidden['password', 'remember_token'] (hidden in toArray()/toJson() output).

Casts

protected function casts(): array
{
    return [
        'email_verified_at' => 'datetime',  // Carbon instance
        'password' => 'hashed',              // Hash::make() on assignment
    ];
}

Traits

Trait Adds
Illuminate\Database\Eloquent\Factories\HasFactory<UserFactory> User::factory() static method
Illuminate\Notifications\Notifiable $user->notify(...) and notification routing

The base class Illuminate\Foundation\Auth\User as Authenticatable adds:

  • Authenticatable interface (getAuthIdentifier, getAuthPassword, etc.)
  • Authorizable trait ($user->can(...))
  • CanResetPassword interface
  • MustVerifyEmail is not implemented by default (commented import in the file)

Factory

Database\Factories\UserFactory defines:

Field Default
name fake()->name()
email fake()->unique()->safeEmail()
email_verified_at now()
password Cached Hash::make('password') — same hash each call
remember_token Str::random(10)

States:

  • unverified() — sets email_verified_at to null.

password_reset_tokens table

Same migration. No model — the framework's password reset broker (Illuminate\Auth\Passwords\DatabaseTokenRepository) reads/writes directly via the query builder.

Column Type Nullable Notes
email varchar(255) No Primary key
token varchar(255) No
created_at timestamp Yes

The token expiry (60 minutes) and throttle (60 seconds) are configured in config/auth.php under passwords.users.

sessions table

Same migration. No model. The database session driver (Illuminate\Session\DatabaseSessionHandler) reads/writes via the query builder.

Column Type Nullable Notes
id varchar(255) No Primary key (session ID)
user_id bigint Yes Indexed; foreign-key shape
ip_address varchar(45) Yes
user_agent text Yes
payload longtext No Serialized session data (JSON by default — see config/session.php 'serialization' => 'json')
last_activity int No Indexed; unix timestamp

cache table

Created by database/migrations/0001_01_01_000001_create_cache_table.php. No model.

Column Type Nullable Notes
key varchar(255) No Primary key
value mediumtext No Stored opaquely; deserialization is restricted by cache.serializable_classes
expiration bigint No Indexed; unix timestamp

cache_locks table

Same migration. Used by Cache::lock() (atomic mutual-exclusion locks).

Column Type Nullable Notes
key varchar(255) No Primary key
owner varchar(255) No
expiration bigint No Indexed

jobs table

Created by database/migrations/0001_01_01_000002_create_jobs_table.php. Used by the database queue driver.

Column Type Nullable Notes
id bigint (PK) No auto-increment
queue varchar(255) No Indexed
payload longtext No Serialized job
attempts smallint No Unsigned
reserved_at int Yes Unsigned; null until a worker reserves
available_at int No Unsigned
created_at int No Unsigned

job_batches table

Same migration. Used by Bus::batch(...) for tracking batched jobs.

Column Type Nullable Notes
id varchar(255) No Primary key (UUID)
name varchar(255) No
total_jobs int No
pending_jobs int No
failed_jobs int No
failed_job_ids longtext No
options mediumtext Yes
cancelled_at int Yes
created_at int No
finished_at int Yes

failed_jobs table

Same migration. Default driver is database-uuids (per config/queue.php).

Column Type Nullable Notes
id bigint (PK) No auto-increment
uuid varchar(255) No Unique
connection text No
queue text No
payload longtext No
exception longtext No
failed_at timestamp No useCurrent() default

Schema diagram

erDiagram
    USERS ||--o{ SESSIONS : "user_id (nullable FK)"
    USERS {
        bigint id PK
        string name
        string email UK
        timestamp email_verified_at
        string password
        string remember_token
    }
    PASSWORD_RESET_TOKENS {
        string email PK
        string token
        timestamp created_at
    }
    SESSIONS {
        string id PK
        bigint user_id
        string ip_address
        text user_agent
        longtext payload
        int last_activity
    }
    CACHE { string key PK; mediumtext value; bigint expiration }
    CACHE_LOCKS { string key PK; string owner; bigint expiration }
    JOBS {
        bigint id PK
        string queue
        longtext payload
        smallint attempts
        int reserved_at
        int available_at
        int created_at
    }
    JOB_BATCHES {
        string id PK
        string name
        int total_jobs
        int pending_jobs
        int failed_jobs
        longtext failed_job_ids
        mediumtext options
        int cancelled_at
        int created_at
        int finished_at
    }
    FAILED_JOBS {
        bigint id PK
        string uuid UK
        text connection
        text queue
        longtext payload
        longtext exception
        timestamp failed_at
    }

The only direct foreign-key shape is sessions.user_id → users.id. Cache, queue, and failed-jobs tables have no FK relationships — they're addressed by string keys, queue names, or UUIDs.

For the migration source code, see Systems → Database.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Data models – Laravel wiki | Factory