Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Url Manager Laravel Package

rayzenai/url-manager

Laravel package to manage URLs, redirects, SEO metadata, visit tracking, and XML sitemaps, with redirect-loop protection and automatic old→new slug redirects. Includes Filament 4 admin panel integration (UrlInput) and optional media SEO via file-manager.

View on GitHub
Deep Wiki
Context7

View Count Tracking

The URL Manager package now supports automatic view count tracking for models that use the HasUrl trait.

How It Works

When a URL is visited, the RecordUrlVisit job is dispatched which:

  1. Increments the URL's visit count
  2. Updates the URL's last_visited_at timestamp
  3. Checks if the model has a getViewCountColumn() method
  4. If the method exists and returns a column name, increments that column

Implementation

To enable view count tracking for your model:

1. Add the view count column to your database

Schema::table('your_table', function (Blueprint $table) {
    $table->integer('view_count')->default(0);
});

2. Implement the getViewCountColumn() method in your model

class Entity extends Model
{
    use \RayzenAI\UrlManager\Traits\HasUrl;
    
    /**
     * Get the view count column name for URL visit tracking
     */
    public function getViewCountColumn(): ?string
    {
        return 'view_count'; // Return the column name
    }
}

If your model doesn't track view counts, return null:

public function getViewCountColumn(): ?string
{
    return null; // No view count tracking
}

Benefits

This approach avoids expensive Schema::hasColumn() checks on every request by using a simple method check instead. Models explicitly declare their view count column, making the system more efficient and predictable.

Custom Visit Tracking

For more advanced tracking needs, you can also implement a recordVisit() method in your model:

public function recordVisit(?int $userId, array $metadata = []): void
{
    // Custom visit tracking logic
    // e.g., track unique visitors, geographic data, etc.
}

This method will be called automatically by the RecordUrlVisit job if it exists on your model.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin