PHPackages                             durjaygp/durjay-views - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. durjaygp/durjay-views

ActiveLibrary[Templating &amp; Views](/categories/templating)

durjaygp/durjay-views
=====================

A unified polymorphic view counter for Laravel models.

1.1(4w ago)11MITBladePHP ^8.2

Since May 5Pushed 4w agoCompare

[ Source](https://github.com/durjaygp/durjay-views)[ Packagist](https://packagist.org/packages/durjaygp/durjay-views)[ RSS](/packages/durjaygp-durjay-views/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

Durjay Views
============

[](#durjay-views)

[![Durjay Views](screenshoot/thumbnail.jpg)](screenshoot/thumbnail.jpg)

A simple view counter for Laravel. Track views for Blogs, Products, Services, and more in a single table using a helper function or a trait. It also includes an awesome Tailwind-designed dashboard for statistics.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require durjaygp/durjay-views
```

Setup
-----

[](#setup)

1. Publish the migration and views (optional):

```
php artisan vendor:publish --provider="Durjaygp\DurjayViews\DurjayViewsServiceProvider"
```

2. Run the migrations:

```
php artisan migrate
```

Usage
-----

[](#usage)

### Using the Helper Function

[](#using-the-helper-function)

You can easily track views for any entity using the provided global helper function:

```
// Parameters: string $type, int $typeId
trackDurjayViews('product', $product->id);
trackDurjayViews('blog', $blog->id);
```

### Using the Trait

[](#using-the-trait)

Alternatively, you can add the `Viewable` trait to your models:

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Durjaygp\DurjayViews\Traits\Viewable;

class Product extends Model {
    use Viewable;
}
```

Then you can record a view directly on the model instance:

```
$product->recordDurjayView();
```

To get the total view count (sum of all `views` increments):

```
echo $product->view_count;
```

Dashboard Statistics
--------------------

[](#dashboard-statistics)

This package provides a beautifully crafted Tailwind CSS dashboard to visualize your application's views.

[![Views Dashboard](screenshoot/dashboard.png)](screenshoot/dashboard.png)

You can access the statistics dashboard at: `/durjay-views/stats`

The dashboard includes:

- View statistics for **Today** and **Yesterday**
- **Total Unique** and **Today Unique** Views metrics
- A gorgeous 7-day **Views Chart**
- A **Recent Views Activity** table (displays Type, User/Guest, Date, and Total Views)

You can publish the views to customize the design:

```
php artisan vendor:publish --provider="Durjaygp\DurjayViews\DurjayViewsServiceProvider" --tag="views"
```

Admin Route (Protected Access)
------------------------------

[](#admin-route-protected-access)

By default the dashboard is accessible at `/durjay-views/stats`. If you want to protect it behind authentication or admin middleware, publish the config and set your preferred middleware:

```
php artisan vendor:publish --provider="Durjaygp\DurjayViews\DurjayViewsServiceProvider" --tag="config"
```

Then update `config/durjay-views.php`:

```
return [
    /*
    |--------------------------------------------------------------------------
    | Dashboard Middleware
    |--------------------------------------------------------------------------
    | Middleware applied to the /durjay-views/stats route.
    | Use 'auth' to restrict to logged-in users, or 'auth,admin' for admins.
    |
    */
    'middleware' => ['web', 'auth'],
];
```

The route is registered automatically — no extra steps needed after changing the config.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance94

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

2

Last Release

29d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/170543b01c3d7b11cbbce2e3cf3aaebd11f1c32baaaba6d0d7b3b15ac1dfa603?d=identicon)[durjaygp](/maintainers/durjaygp)

---

Top Contributors

[![durjaygp](https://avatars.githubusercontent.com/u/42237029?v=4)](https://github.com/durjaygp "durjaygp (7 commits)")

### Embed Badge

![Health badge](/badges/durjaygp-durjay-views/health.svg)

```
[![Health](https://phpackages.com/badges/durjaygp-durjay-views/health.svg)](https://phpackages.com/packages/durjaygp-durjay-views)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[moonshine/moonshine

Laravel administration panel

1.3k239.9k72](/packages/moonshine-moonshine)[illuminate/view

The Illuminate View package.

13046.3M2.1k](/packages/illuminate-view)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

719160.4k12](/packages/tallstackui-tallstackui)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45344.0k1](/packages/pressbooks-pressbooks)[hasinhayder/tyro-dashboard

Tyro Dashboard - Beautiful admin dashboard for managing Tyro roles, privileges, users, and settings

5222.7k](/packages/hasinhayder-tyro-dashboard)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
