Skip to Content
Data Models And Database Schema

Last Updated: 3/17/2026


Data Models and Database Schema

LinkAce is built on Laravel and uses Eloquent ORM for database interactions. This document describes the core data models and their relationships.

Core Models Overview

LinkAce has five primary models:

  1. Link - A bookmarked URL with metadata
  2. LinkList - A collection/category for organizing links
  3. Tag - A label for categorizing links
  4. Note - A text note attached to a link
  5. User - A user account

The Link model represents a bookmarked URL and is the central entity in LinkAce.

Fields

FieldTypeDescription
idintegerPrimary key
user_idintegerForeign key to User
urlstringThe bookmarked URL
titlestringTitle of the link
descriptionstring (nullable)Description text (supports Markdown)
iconstring (nullable)Icon identifier
visibilityintegerVisibility level (1=private, 2=internal, 3=public)
statusintegerHealth check status (1=OK, 2=moved, 3=broken)
check_disabledbooleanWhether automated checks are disabled
last_checked_atdatetime (nullable)Last health check timestamp
thumbnailstring (nullable)Thumbnail URL
created_atdatetimeCreation timestamp
updated_atdatetimeLast update timestamp
deleted_atdatetime (nullable)Soft delete timestamp

Relationships

  • belongsTo: User - The link owner
  • belongsToMany: LinkList - Lists containing this link (via link_lists pivot table)
  • belongsToMany: Tag - Tags applied to this link (via link_tags pivot table)
  • hasMany: Note - Notes attached to this link

Status Constants

const STATUS_OK = 1; // Link is accessible const STATUS_MOVED = 2; // Link redirected const STATUS_BROKEN = 3; // Link is broken

Key Methods

  • shortUrl(): Returns URL without http(s):// prefix
  • shortTitle($maxLength): Returns truncated title
  • domainOfURL(): Extracts domain from URL
  • getFormattedDescriptionAttribute(): Returns Markdown-formatted description
  • searchDuplicateUrls(): Finds potential duplicate links
  • initiateInternetArchiveBackup(): Queues Wayback Machine backup

Scopes

  • byUser($user_id): Filter links by user
  • privateOnly(): Only private links
  • internalOnly(): Only internal links
  • publicOnly(): Only public links

The LinkList model represents a collection or category of links.

Fields

FieldTypeDescription
idintegerPrimary key
user_idintegerForeign key to User
namestringList name
descriptionstring (nullable)Description (supports Markdown)
visibilityintegerVisibility level (1=private, 2=internal, 3=public)
created_atdatetimeCreation timestamp
updated_atdatetimeLast update timestamp
deleted_atdatetime (nullable)Soft delete timestamp

Relationships

  • belongsTo: User - The list owner
  • belongsToMany: Link - Links in this list (via link_lists pivot table)

Key Methods

  • getFormattedDescriptionAttribute(): Returns Markdown-formatted description

Ordering

Lists are automatically ordered by name (via OrderNameScope global scope).

Tag Model

The Tag model represents a label for categorizing links.

Fields

FieldTypeDescription
idintegerPrimary key
user_idintegerForeign key to User
namestringTag name
visibilityintegerVisibility level (1=private, 2=internal, 3=public)
created_atdatetimeCreation timestamp
updated_atdatetimeLast update timestamp
deleted_atdatetime (nullable)Soft delete timestamp

Relationships

  • belongsTo: User - The tag owner
  • belongsToMany: Link - Links with this tag (via link_tags pivot table)

Ordering

Tags are automatically ordered by name (via OrderNameScope global scope).

Note Model

The Note model represents a text note attached to a link.

Fields

FieldTypeDescription
idintegerPrimary key
link_idintegerForeign key to Link
user_idintegerForeign key to User
notetextNote content (supports Markdown)
created_atdatetimeCreation timestamp
updated_atdatetimeLast update timestamp
deleted_atdatetime (nullable)Soft delete timestamp

Relationships

  • belongsTo: Link - The associated link
  • belongsTo: User - The note author

User Model

The User model represents a user account in LinkAce.

Fields

FieldTypeDescription
idintegerPrimary key
namestringUser’s display name
emailstringEmail address (unique)
passwordstringHashed password
email_verified_atdatetime (nullable)Email verification timestamp
is_adminbooleanAdmin flag
created_atdatetimeCreation timestamp
updated_atdatetimeLast update timestamp
deleted_atdatetime (nullable)Soft delete timestamp

Relationships

  • hasMany: Link - Links owned by this user
  • hasMany: LinkList - Lists owned by this user
  • hasMany: Tag - Tags owned by this user
  • hasMany: Note - Notes created by this user

Pivot Tables

Links the links and lists tables in a many-to-many relationship.

FieldTypeDescription
link_idintegerForeign key to links
list_idintegerForeign key to lists

Links the links and tags tables in a many-to-many relationship.

FieldTypeDescription
link_idintegerForeign key to links
tag_idintegerForeign key to tags

Visibility System

All primary models (Link, LinkList, Tag) support a three-level visibility system:

LevelConstantDescription
1VISIBILITY_PRIVATEOnly visible to the owner
2VISIBILITY_INTERNALVisible to all authenticated users
3VISIBILITY_PUBLICVisible to everyone, including guests

The visibility system is implemented via the ScopesVisibility trait, which provides query scopes for filtering resources by visibility level.

Soft Deletes

All core models use Laravel’s soft delete feature. When a record is deleted, it’s marked with a deleted_at timestamp rather than being permanently removed from the database. This allows for:

  • Trash/restore functionality
  • Audit trail preservation
  • Relationship integrity maintenance

Audit Trail

LinkAce uses the owen-it/laravel-auditing package to track changes to models. All core models implement the Auditable interface and maintain a complete audit log of:

  • Create, update, and delete operations
  • Field-level changes with old and new values
  • Relationship modifications
  • User attribution

Custom audit modifiers format certain fields for better readability:

  • VisibilityModifier: Formats visibility levels
  • BooleanModifier: Formats boolean values
  • LinkStatusModifier: Formats link status codes
  • TagRelationModifier / ListRelationModifier: Formats relationship changes

Repository Pattern

LinkAce uses the Repository pattern for complex business logic. Key repositories include:

  • LinkRepository: Handles link creation, updates, and deletion with associated relationships
  • Creates/updates lists and tags inline
  • Manages Internet Archive backups
  • Handles duplicate detection

Model Traits

ScopesForUser

Provides the byUser() query scope for filtering resources by user ownership.

ScopesVisibility

Provides query scopes for visibility filtering:

  • privateOnly()
  • internalOnly()
  • publicOnly()
  • visibleForUser($userId, $privateSystemAccess)

ProvidesTaxonomyOutput

Used by Link model to provide formatted output for taxonomy relationships (lists and tags).

Database Migrations

LinkAce uses Laravel migrations for schema management. All migrations are version-controlled and can be found in the database/migrations directory. Key migrations include:

  • User and authentication tables
  • Core model tables (links, lists, tags, notes)
  • Pivot tables for many-to-many relationships
  • Audit and session tables
  • OAuth/SSO tables

For collation settings and database-specific configuration, see Adjusting the Database Collation.