Download the PHP package atldays/laravel-eloquent-join-relation without Composer

On this page you can find all versions of the php package atldays/laravel-eloquent-join-relation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-eloquent-join-relation

Laravel Eloquent Join Relation

Latest Version on Packagist Total Downloads CI

Laravel is great at working with relations, but as soon as a query becomes more complex and starts using join, loading relations through with() or lazy loading often leads to additional queries. The required data was already returned by the main SQL query.

This package solves that problem by letting you keep a single SQL query with join while still getting fully hydrated relations, as if they had been loaded through Eloquent in the usual way.

If you already joined a related table for filtering, sorting, or conditional checks, the package can build the relation directly from that joined data and set it on the model without touching the database again.

It is especially useful in complex queries that involve multiple related tables, where you still want to work with them afterward as normal nested Laravel relations.

Highlights

Support

Current boundaries

Installation

Basic usage

If you already join a related table, you can hydrate that relation without an extra query.

The generated SQL will look roughly like this:

That means:

Nested relation paths

For common BelongsTo chains, you can hydrate nested relations step by step.

The generated SQL will look roughly like this:

Important:

If you skip an earlier level, the package throws an exception instead of silently falling back to lazy loading.

Left joins and nullable relations

For optional relations, use type: 'left'.

The generated SQL will look roughly like this:

The same applies to nested paths:

The generated SQL will look roughly like this:

If the joined team row is missing, author->team becomes null.

Manual hydrate mode

When the join is custom, or when you want to put the hydrated model somewhere non-standard, use related + join + hydrate.

This is especially useful when you already joined several tables and want to attach a model deeper in the tree yourself.

The generated SQL will look roughly like this:

If the profile is missing on a left join, the callback receives null.

Advanced example

Here is the same style of query for a deeper chain where every level is required.

This gives you one SQL query and fully hydrated nested relations with no follow-up lazy-loading queries.

The resulting SQL will look roughly like this:

That is the main point of the package:

What you save compared to with()

For queries that already depend on joins, a classic eager-loading approach often turns into:

  1. one query for the root records
  2. one query for author
  3. one query for author.team
  4. one query for author.team.organization

With joinRelation(...), those joined records are hydrated from the same SQL result set, so relation access does not need those extra follow-up queries.

How it differs from with()

with() is still great when you want classic eager loading.

This package is useful when:

Testing status

The package test suite covers:


All versions of laravel-eloquent-join-relation with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package atldays/laravel-eloquent-join-relation contains the following files

Loading the files please wait ...