Overview
TheLink model represents shortened URLs in LaraCMS’s URL shortener feature. Each link belongs to a user and tracks URL redirects for analytics and marketing purposes.
Namespace: App\Models\Link
File: app/Models/Link.php:7
Properties
Mass assignment
This model uses$guarded = [], meaning all attributes are mass-assignable. Based on the migration schema, the model likely contains:
The ID of the user who created the link
The short URL slug (e.g., “abc123”)
The original full URL to redirect to
Number of times the link has been clicked
Relationships
user()
Belongs to relationship with the User model. Returns:BelongsTo<User>
Usage examples
Creating a shortened link
Tracking clicks
Querying links
Generating unique slugs
Database schema
Based on the migration file2025_09_06_175723_create_links_table.php, the links table contains:
id- Primary keyuser_id- Foreign key to users tableslug- Short URL identifier (string, unique)url- Original URL (text)clicks- Click counter (integer, default 0)created_at- Timestampupdated_at- Timestamp
URL shortener feature
The Link model is used by the admin URL shortener tool at
/admin/url-shortener. See the URL tools documentation for more details on the user interface.Related documentation
User model
View User model documentation
URL tools
Learn about URL shortener admin interface