PHPackages                             syrian-open-source/laravel-relational-metrics - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. syrian-open-source/laravel-relational-metrics

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

syrian-open-source/laravel-relational-metrics
=============================================

This package will help you to get your model metrics, and their related models' metrics which will help you to avoid writing to many requests or queries.

v1.2.0(4y ago)2692[2 issues](https://github.com/Syrian-Open-Source/laravel-relational-metrics/issues)MITPHP

Since Mar 11Pushed 4y ago3 watchersCompare

[ Source](https://github.com/Syrian-Open-Source/laravel-relational-metrics)[ Packagist](https://packagist.org/packages/syrian-open-source/laravel-relational-metrics)[ RSS](/packages/syrian-open-source-laravel-relational-metrics/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (2)Versions (9)Used By (0)

[![logo](assets/logo.png)](assets/logo.png)

[![PHP Composer](https://github.com/Syrian-Open-Source/laravel-relational-metrics/actions/workflows/php.yml/badge.svg)](https://github.com/syrian-open-source/laravel-multi-process/actions/workflows/php.yml)[![Run tests](https://github.com/Syrian-Open-Source/laravel-relational-metrics/actions/workflows/tests.yml/badge.svg)](https://github.com/syrian-open-source/laravel-multi-process/actions/workflows/tests.yml)

Relational Metrics
==================

[](#relational-metrics)

This package will help you to make your metrics easier, You could get metrics about your Models, Models depending on their relations, or even metrics about your models depending on multiple conditions!!

It would be a very easy to get the number of your stores which has products has a price more than x$ ;)

##### 1 - Dependency

[](#1---dependency)

The first step is using composer to install the package and automatically update your composer.json file, you can do this by running:

```
composer require syrian-open-source/laravel-relational-metrics
```

Usage
-----

[](#usage)

```
        // first you must make a model from facade class
        // like post model
        $instance = \SOS\RelationalMetrics\Facades\RelationalMetricsFacade::setModel("Post");
        // or you can specify thr model name by this way:  RelationalMetricsFacade::setModel(Store::class);
```

The Basic Usage of this package is the same of getting count of some model instances, but with a styled response

```
        $metrics = $instance->getBasicMetrics();
        // or you can get the count or the message directly.
        $directCount = $instance->getCount();
        $directName = $instance->getName();

        /*
	  *     Response will be like:
	  *	[
	  *	    'name' => 'Total Stores Number,
	  *	    'count' => 43,
	  *	];
	  *
        */
```

What you can do next, you could get the metrics of a model depending on one of its relations!

Let's assume we want to get the number of stores that has products with price more than 500

```
        $metrics = $instance->getRelationalMetrics($relationName, $relationColumn, $value);
        // example: $instance->getRelationalMetrics('products, 'price', 500);
        /*
	  *     Response will be like:
	  *	[
	  *	    'name' => 'Total Stores Number,
	  *	    'count' => 12,
	  *	];
	  *
        */
```

At the previous Example the Package will return the number of the stores which has products with price equals to 500

And last but not least, You could get the metrics about a model depending on any number of conditions you want!

```
        // example for the conditions
        $conditions = [
                  ['method' => 'where', 'column' => 'address', 'operator' => 'like', 'value' => '%UAE%'],
                  ['method' => 'where', 'column' => 'rate', 'operator' => '>', 'value' => 3],
        ];
        $metrics = $instance->getRelationalMetrics($conditions);

        /*
	  *     Response will be like:
	  *	[
	  *	    'name' => 'Total Stores Number,
	  *	    'count' => 2,
	  *	];
	  *
        */
```

At the previous Example the Package will return the number of the stores where their address contains "UAE" and their rate is more than 3

Changelog
---------

[](#changelog)

Please see the [CHANGELOG](https://github.com/syrian-open-source/laravel-relational-metrics/blob/master/CHANGELOG.md) for more information about what has changed or updated or added recently.

Security
--------

[](#security)

If you discover any security related issues, please email them first to , if we do not fix it within a short period of time please open a new issue describing your problem.

Credits
-------

[](#credits)

- [Zain Aldeen Fayod](https://www.linkedin.com/in/zainaldeenfayod/)
- [All contributors](https://github.com/syrian-open-source/laravel-relational-metrics/graphs/contributors)

Package Logo by
---------------

[](#package-logo-by)

- [Abdussalam Al-Ali](https://github.com/abdussalam-alali)

About Syrian Open Source
------------------------

[](#about-syrian-open-source)

The Syrian Open Source platform is the first platform on GitHub dedicated to bringing Syrian developers from different cultures and experiences together, to work on projects in different languages, tasks, and versions, and works to attract Syrian developers to contribute more under one platform to open source software, work on it, and issue it with high quality and advanced engineering features, which It stimulates the dissemination of the open-source concept in the Syrian software community, and also contributes to raising the efficiency of developers by working on distributed systems and teams.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 72.2% 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 ~2 days

Total

6

Last Release

1565d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/56937091?v=4)[karam2mustafa](/maintainers/karam2mustafa)[@karam2mustafa](https://github.com/karam2mustafa)

---

Top Contributors

[![karam-mustafa](https://avatars.githubusercontent.com/u/71431942?v=4)](https://github.com/karam-mustafa "karam-mustafa (39 commits)")[![zainaldeen](https://avatars.githubusercontent.com/u/48657261?v=4)](https://github.com/zainaldeen "zainaldeen (10 commits)")[![foobar2016](https://avatars.githubusercontent.com/u/22450506?v=4)](https://github.com/foobar2016 "foobar2016 (4 commits)")[![RoduanKD](https://avatars.githubusercontent.com/u/37983260?v=4)](https://github.com/RoduanKD "RoduanKD (1 commits)")

---

Tags

laravellaravel-packagemetricssyriasyrian-open-sourcelaravelMetricsrelationsrelationalsyrian-open-source

### Embed Badge

![Health badge](/badges/syrian-open-source-laravel-relational-metrics/health.svg)

```
[![Health](https://phpackages.com/badges/syrian-open-source-laravel-relational-metrics/health.svg)](https://phpackages.com/packages/syrian-open-source-laravel-relational-metrics)
```

###  Alternatives

[chelout/laravel-relationship-events

Missing relationship events for Laravel

5272.5M17](/packages/chelout-laravel-relationship-events)[sakanjo/laravel-easy-metrics

Generate metrics with ease and precision.

31745.6k1](/packages/sakanjo-laravel-easy-metrics)[jubeki/laravel-code-style

Combine Custom Fixers with the ruleset of Laravel Pint to fix your code style in Laravel Applications/Packages.

56570.4k8](/packages/jubeki-laravel-code-style)[square1/nova-metrics

Add support for resource-filters on your laravel nova metrics

27284.4k](/packages/square1-nova-metrics)[saintsystems/nova-linkable-metrics

Linkable metrics for Laravel Nova 4.x.

21317.9k](/packages/saintsystems-nova-linkable-metrics)[syrian-open-source/laravel-youtube-iframe-generator

Laravel package allows you to generate an iframe tag with a video player depending on a youtube URL.

184.2k](/packages/syrian-open-source-laravel-youtube-iframe-generator)

PHPackages © 2026

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