Weave Code
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.
croct/coding-standard
croct/plug-php
nqxcode/phpmorphy
boundwize/pyrameter
testo/facade
develia/commons
dmstr/symfony-system-resources-bundle
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
renatomarinho/laravel-page-speed
develia/geo-bundle
austinheap/laravel-database-encryption
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
imbo/imbo-coding-standard
visualbuilder/filament-lottie
servicioslineaonce/starter-kit
atomcoder/laravel-reorderable
irajul/filament-shadcn-theme