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 2d 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 32% 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://www.gravatar.com/avatar/8cc0c866fa661f5889c2a07b0ec98f33dd431341e07bda09ba47d60beeabf62c?d=identicon)[aciddose](/maintainers/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

[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)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

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

Reliese Components for Laravel Framework code generation.

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

PHPackages © 2026

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