New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

hellomohsinhello/laravel-relation-parser

Easily load model relations from frontend without changing your API
1,194

Larablocks Analysis

hellomohsinhello/laravel-relation-parser works with Laravel 10, 11 and 12 (latest release 1.0.4, Jul 6, 2026).

Recommendation checks

Use with care

Use with care: meets 1 of 4 checks.

  • Latest release doesn't support Laravel 13, the current version
  • Released in the last 12 months (Jul 6, 2026)
  • 426 downloads a month (needs 10,000)
  • 0 GitHub stars (needs 100)

State

Maintained
  • Last stable release: Jul 6, 2026.
  • 2 releases in the last 12 months.
  • First released: Mar 6, 2025.
  • Monthly downloads: 426.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 4, 2026.

Install
composer require hellomohsinhello/laravel-relation-parser
Latest Version:1.0.4
PHP:>=8.2
Laravel:10 · 11 · 12
License:MIT
Last Updated:Jul 6, 2026
Links: GitHub  ·  Packagist
Maintainer: hellomohsinhello

Latest Version on Packagist Total Downloads MIT Licensed

Installation

composer require salamwaddah/laravel-relation-parser
Version Laravel PHP
1.x 10, 11 >= 8.1
0.3.x 8, 9, 10 >= 7.3

Usage

Allow your application to load any model relation in the response without the need of changing your API controllers.

Pass a comma separated relations to your http request.

Loading relations

Add a with param to your HTTP request

/users?with=orders,posts,anyOtherRelation

Loading relation counts

Add a with_count param to your HTTP request

/users?with_count=orders,anyOtherRelation,anotherRelationToCount,blaBlaBla

Loading relations and counts

/users?with=orders&with_count=orders

In your controller

use SalamWaddah\RelationParser\LoadsRelations;
use Illuminate\Http\Request;

class UsersController extends Controller
{
    use LoadsRelations;
    
    public function index(Request $request)
    {
            $users = User::query()
                // .. your query logic here
                ->get();
    
            // this line adds the relations/counts
            $this->loadRelations($users, $request);
    
            // return your results however you like
            return response()->json($users);
        }
    }

Response example

[
  {
    "id": 1,
    "name": "Salam",
    "orders_count": 2,
    "orders": [
      {
        "id": 2,
        "product": "something",
        "price": 100
      },
      {
        "id": 1,
        "product": "something else",
        "price": 150
      }
    ]
  },
  {
    "id": 2,
    "name": "Naren",
    "orders_count": 1,
    "orders": [
      {
        "id": 3,
        "product": "something",
        "price": 100
      }
    ]
  }
]

Customize

If with or with_count params are used for something else in your application then you can customize those params in loadRelations() method.

$this->loadRelations($users, $request, 'customWithParam', 'custom_with_count_param');

Testing

composer test

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

670,032,257 9,703
laravel/framework

The Laravel Framework.

640,572,096 35,338
laravel/tinker

Powerful REPL for the Laravel framework.

546,909,908 7,440
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

465,816,364 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

431,187,642 4,660

Version History

Version Released PHP Laravel License
1.0.4 >=8.2 ^10.0 || ^11.0 || ^12.0 MIT
1.0.3 >=8.2 ^10.0 || ^11.0 || ^12.0 MIT
1.0.2 >=8.2 ^10.0 || ^11.0 MIT
1.0.1 >=8.2 ^10.0 || ^11.0 MIT
1.0.0 >=8.2 ^10.0 || ^11.0 MIT