PHPackages                             aciddose/laravel-request-relationships - 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. aciddose/laravel-request-relationships

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

aciddose/laravel-request-relationships
======================================

A model Trait for Laravel that let's you automatically load model's relationships by defining then in request parameters

24.0kPHP

Since Oct 28Pushed 8y ago1 watchersCompare

[ Source](https://github.com/teeli/laravel-request-relationships)[ Packagist](https://packagist.org/packages/aciddose/laravel-request-relationships)[ RSS](/packages/aciddose-laravel-request-relationships/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-request-relationships
=============================

[](#laravel-request-relationships)

Laravel-request-relationships provides a model trait for laravel that automatically loads model's relationships when they are defined in the request. The loaded relationships are defined in the URL in the same format as loading Eloquent relationships, e.g. `http://www.example.com/api/article/1?with=author,comments,comments.author`

Requirements
------------

[](#requirements)

This package requires PHP &gt;= 7.0 and has been Laravel &gt;= 5.0. It will probably work with any Eloquent implementation, but it's not officially supported (at least yet)

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

[](#installation)

Laravel-request-relationships is distributed as a composer package. You can install it by adding it to your `composer.json` file:

```
"require": {
  "aciddose/laravel-request-relationships": "*"
}
```

If you want to customize the URL query parameter name, add the service provider to the providers array in your `config/app.php` config file:

```
Aciddose\RequestRelationships\ServiceProvider::class,
```

Them run the following command to create a configuration file:

```
php artisan vendor:publish --provider=Aciddose\\RequestRelationships\\ServiceProvider

```

Then open `config/requestrelationships.php` and change the `default_parameter_name` to whatever you want.

Usage
-----

[](#usage)

The package provides a trait that you need to add to any model you want the autoloading to work with.

```
use \Illuminate\Database\Eloquent\Model;
use \Aciddose\RequestRelationships\Traits\RequestRelationships;

class Article extends Model {
    use RequestRelationships;

    /**
     * Parameter name can be defined optionally for each model. If it's not defined, the default
     * parameter name from configuration is used (or `with` if no configuration is defined)
     */
    $requestRelationsParamName = 'with';

    public function author() {
        return $this->belongsTo('App\Users', 'user_id', 'id');
    }
}
```

After defining the trait (and assuming you have a working route), you can just define the relationships in your request:

`http://www.example.com/api/article/1?with=author,comments,comments.author`

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![teeli](https://avatars.githubusercontent.com/u/294353?v=4)](https://github.com/teeli "teeli (1 commits)")

---

Tags

laravellaravel-5-packagelaravel-packagelaravel5phpphp7

### Embed Badge

![Health badge](/badges/aciddose-laravel-request-relationships/health.svg)

```
[![Health](https://phpackages.com/badges/aciddose-laravel-request-relationships/health.svg)](https://phpackages.com/packages/aciddose-laravel-request-relationships)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198628.3k10](/packages/pgvector-pgvector)

PHPackages © 2026

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