Skip to Content
Developer GuideData Models

Last Updated: 3/16/2026


Data Models

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

Core Models

The Link model represents a bookmarked URL.

Location: app/Models/Link.php

Key Properties:

  • id - Primary key
  • user_id - Foreign key to User
  • url - The bookmarked URL
  • title - Link title
  • description - Optional description
  • icon - Icon identifier
  • visibility - Access level (1=private, 2=internal, 3=public)
  • status - Health status (1=OK, 2=Moved, 3=Broken)
  • check_disabled - Disable automatic health checks
  • last_checked_at - Last health check timestamp
  • thumbnail - Optional thumbnail URL

Relationships:

  • user() - BelongsTo User
  • lists() - BelongsToMany LinkList (via link_lists pivot)
  • tags() - BelongsToMany Tag (via link_tags pivot)
  • notes() - HasMany Note

Key Methods:

  • getFormattedDescriptionAttribute() - Returns markdown-formatted description
  • shortUrl() - Returns URL without https://
  • shortTitle($maxLength) - Returns truncated title
  • domainOfURL() - Extracts domain from URL
  • getIcon($additionalClasses) - Generates icon HTML with status indicators
  • initiateInternetArchiveBackup() - Triggers Wayback Machine archival
  • searchDuplicateUrls() - Finds similar URLs

Scopes:

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

Represents a collection of links.

Location: app/Models/LinkList.php

Relationships:

  • user() - BelongsTo User
  • links() - BelongsToMany Link

Tag

Represents a tag for categorizing links.

Location: app/Models/Tag.php

Relationships:

  • user() - BelongsTo User (creator)
  • links() - BelongsToMany Link

Note

Represents a note attached to a link.

Location: app/Models/Note.php

Relationships:

  • link() - BelongsTo Link
  • user() - BelongsTo User (author)

User

Represents a user account.

Location: app/Models/User.php

Relationships:

  • links() - HasMany Link
  • lists() - HasMany LinkList
  • tags() - HasMany Tag
  • notes() - HasMany Note

Model Traits

ProvidesTaxonomyOutput

Used by Link, LinkList, and Tag models to provide consistent output formatting.

Location: app/Models/ProvidesTaxonomyOutput.php

ScopesForUser

Provides user-scoped query methods.

Location: app/Models/ScopesForUser.php

Methods:

  • scopeByUser($query, $user_id) - Filter by user ID

ScopesVisibility

Provides visibility-scoped query methods.

Location: app/Models/ScopesVisibility.php

Methods:

  • scopePrivateOnly($query) - Private items only
  • scopeInternalOnly($query) - Internal items only
  • scopePublicOnly($query) - Public items only
  • scopeVisibleForUser($query, $privateSystemAccess) - Items visible to current user

API Models

API-specific models extend the base models and provide additional API functionality.

Location: app/Models/Api/

  • ApiLink - Extends Link for API responses
  • ApiLinkList - Extends LinkList for API responses
  • ApiTag - Extends Tag for API responses

Soft Deletes

The following models support soft deletion:

  • Link
  • LinkList
  • Tag
  • Note
  • User

Soft-deleted items are moved to trash and can be restored or permanently deleted.

Auditing

LinkAce uses the owen-it/laravel-auditing package to track changes to models.

Audited Models:

  • Link

Audit Configuration:

protected array $auditExclude = ['icon']; public array $auditModifiers = [ 'visibility' => VisibilityModifier::class, 'check_disabled' => BooleanModifier::class, 'status' => LinkStatusModifier::class, ];

Custom Events:

  • relatedModels - Tracks relationship changes (tags, lists)

Database Schema

- id (bigint, primary key) - user_id (bigint, foreign key) - url (text) - title (string) - description (text, nullable) - icon (string, nullable) - visibility (integer) - status (integer) - check_disabled (boolean) - last_checked_at (timestamp, nullable) - thumbnail (string, nullable) - created_at (timestamp) - updated_at (timestamp) - deleted_at (timestamp, nullable)

Pivot Tables

link_lists:

  • link_id (bigint)
  • list_id (bigint)

link_tags:

  • link_id (bigint)
  • tag_id (bigint)

Constants

Link::STATUS_OK = 1; Link::STATUS_MOVED = 2; Link::STATUS_BROKEN = 3;
Link::DISPLAY_CARDS = 1; Link::DISPLAY_LIST_SIMPLE = 2; Link::DISPLAY_LIST_DETAILED = 3;

Model Factories

LinkAce uses Laravel factories for testing and seeding.

Location: database/factories/

Factories are available for all core models and can be used in tests:

$link = Link::factory()->create([ 'url' => 'https://example.com', 'title' => 'Test Link', ]);

Next Steps