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
Link
The Link model represents a bookmarked URL.
Location: app/Models/Link.php
Key Properties:
id- Primary keyuser_id- Foreign key to Userurl- The bookmarked URLtitle- Link titledescription- Optional descriptionicon- Icon identifiervisibility- Access level (1=private, 2=internal, 3=public)status- Health status (1=OK, 2=Moved, 3=Broken)check_disabled- Disable automatic health checkslast_checked_at- Last health check timestampthumbnail- Optional thumbnail URL
Relationships:
user()- BelongsTo Userlists()- BelongsToMany LinkList (vialink_listspivot)tags()- BelongsToMany Tag (vialink_tagspivot)notes()- HasMany Note
Key Methods:
getFormattedDescriptionAttribute()- Returns markdown-formatted descriptionshortUrl()- Returns URL without https://shortTitle($maxLength)- Returns truncated titledomainOfURL()- Extracts domain from URLgetIcon($additionalClasses)- Generates icon HTML with status indicatorsinitiateInternetArchiveBackup()- Triggers Wayback Machine archivalsearchDuplicateUrls()- Finds similar URLs
Scopes:
byUser($user_id)- Filter by userprivateOnly()- Only private linksinternalOnly()- Only internal linkspublicOnly()- Only public links
LinkList
Represents a collection of links.
Location: app/Models/LinkList.php
Relationships:
user()- BelongsTo Userlinks()- 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 Linkuser()- BelongsTo User (author)
User
Represents a user account.
Location: app/Models/User.php
Relationships:
links()- HasMany Linklists()- HasMany LinkListtags()- HasMany Tagnotes()- 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 onlyscopeInternalOnly($query)- Internal items onlyscopePublicOnly($query)- Public items onlyscopeVisibleForUser($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 responsesApiLinkList- Extends LinkList for API responsesApiTag- 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
Links Table
- 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
Link::STATUS_OK = 1;
Link::STATUS_MOVED = 2;
Link::STATUS_BROKEN = 3;Link Display Modes
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',
]);