PHPackages                             mfrouh/scope-statistics - 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. [Database &amp; ORM](/categories/database)
4. /
5. mfrouh/scope-statistics

ActiveLibrary[Database &amp; ORM](/categories/database)

mfrouh/scope-statistics
=======================

Package For Scope Statistics on model in day , month , hour, term

1.6(3y ago)12.6kMITPHP

Since Sep 1Pushed 3y ago1 watchersCompare

[ Source](https://github.com/mfrouh/scope-statistics)[ Packagist](https://packagist.org/packages/mfrouh/scope-statistics)[ RSS](/packages/mfrouh-scope-statistics/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)DependenciesVersions (8)Used By (0)

ScopeStatistics
---------------

[](#scopestatistics)

#### Is Package Used In model To Get Count Data In Day , Hour , Month , Term Using Scope

[](#is-package-used-in-model-to-get-count-data-in-day--hour--month--term-using-scope)

```
 composer require mfrouh/scope-statistics
```

#### Add Trait in Your Model

[](#add-trait-in-your-model)

```
use MFrouh\ScopeStatistics\Traits\ScopeStatistics;

class Order extends Model
{
    use ScopeStatistics;

}
```

### Package Has 4 Methods

[](#package-has-4-methods)

### 1- Statistic In Day

[](#1--statistic-in-day)

```
 // by default using column 'created_at'

 $statistic_in_day = Order::statisticInDay();

 // or can use custom column

 $statistic_in_day = Order::statisticInDay('updated_at');

 $cancelled_statistic_in_day = Order::where('status','cancelled')->statisticInDay();

// response will be with 100 Order

 $statistic_in_day =
 [
     "monday" => 8,
     "tuesday" => 16,
     "wednesday" => 13,
     "thursday" => 16,
     "friday" => 12,
     "saturday" => 18,
     "sunday" => 17,
 ]
```

### 2- Statistic In Hour

[](#2--statistic-in-hour)

```
 // by default using column 'created_at'
 // by default using count_hours 6
 // count_hours can be  1, 2, 3, 4, 6, 8, 12

 // every 6 hours
 $statistic_in_hour = Order::statisticInHour();

 // every 3 hours
 $statistic_in_hour = Order::statisticInHour('created_at',3);

 // or can use custom column

 $statistic_in_hour = Order::statisticInHour('updated_at');

 $cancelled_statistic_in_hour = Order::where('status','cancelled')->statisticInHour();

// response will be with 100 Order

$statistic_in_hour =
[
    "00:00:00-05:59:59" => 34,
    "06:00:00-11:59:59" => 17,
    "12:00:00-17:59:59" => 28,
    "18:00:00-23:59:59" => 21,
]
```

### 3- Statistic In Month

[](#3--statistic-in-month)

```
 // by default using column 'created_at'

 $statistic_in_month = Order::statisticInMonth();

 // or can use custom column

 $statistic_in_month = Order::statisticInMonth('updated_at');

 $cancelled_statistic_in_month = Order::where('status','cancelled')->statisticInMonth();

// response will be with 100 Order

 $statistic_in_month =
 [
     "january" => 12,
     "february" => 7,
     "march" => 10,
     "april" => 12,
     "may" => 13,
     "june" => 5,
     "july " => 8,
     "august" => 6,
     "september" => 7,
     "october" => 6,
     "november" => 6,
     "december" => 8,
 ]
```

### 4- Statistic In Term

[](#4--statistic-in-term)

```
 // by default using column 'created_at'
 // by default using count_months 3
 // count_months can be 3,6
 // term1 in 3 month will data in january , february , march

 // every 3 month
 $statistic_in_term = Order::statisticInTerm();

 // every 6 month
 $statistic_in_term = Order::statisticInTerm('created_at',6);

 // or can use custom column

 $statistic_in_term = Order::statisticInTerm('updated_at');

 $cancelled_statistic_in_term = Order::where('status','cancelled')->statisticInTerm();

// response will be with 100 Order

$statistic_in_term =
[
     "term1" => 29,
     "term2" => 30,
     "term3" => 21,
     "term4" => 20,
]
```

### 5- Statistic In One Query

[](#5--statistic-in-one-query)

```
 $array = [
     'completed_order' => Order::where('status', 'completed'),
     'cancelled_order' => Order::where('status', 'cancelled'),
 ];

 $statistic_in_one_query = Order::statisticInOneQuery($array);

// response will be 100 Order

$statistic_in_one_query =
[
  "completed_order" => 75
  "cancelled_order" => 25
]
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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 ~19 days

Total

6

Last Release

1255d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/51133827?v=4)[Mohamed Abdel Ghani](/maintainers/mfrouh)[@mfrouh](https://github.com/mfrouh)

---

Top Contributors

[![mfrouh](https://avatars.githubusercontent.com/u/51133827?v=4)](https://github.com/mfrouh "mfrouh (13 commits)")

### Embed Badge

![Health badge](/badges/mfrouh-scope-statistics/health.svg)

```
[![Health](https://phpackages.com/badges/mfrouh-scope-statistics/health.svg)](https://phpackages.com/packages/mfrouh-scope-statistics)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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