reedware/laravel-relation-joins
Fixes #46
Assertion errors are no longer being thrown to method_exists usage attempting to detect macros.
Laravel 11 reached its end of life support on March 12th, 2026. I have dropped support for Laravel 11 (you can continue using it if you're on the 8.x release), and I've formally added support for Laravel 13.
Fixes #42
An exception is now thrown when a relation in array-syntax goes unused.
Laravel 10 reached its end of life support on February 4th, 2025. I have dropped support for Laravel 10 (you can continue using it if you're on the 7.x release), and I've formally added support for Laravel 12.
PHP 8.1 reached its end of active support life over a year ago (security support will continue until EOY 2025). I have dropped support for PHP 8.1 (you can continue using it if you're on the 6.x release), and I've formally added support for PHP 8.4.
There was also a change within Laravel 11 (#51851) which added generics to relations. I've updated the static analysis within this package to support those generics as well. There may be additional changes in the future as people start trying out query scopes within joins, as PHPStan/Larastan should now be able to detect that the join clause is for a specific model.
The dynamic addition of properties has been deprecated in PHP 8.4, so the ability to modify join types via $join->type = 'left' has been removed, as it relied on this feature. You'll have to piece together your joins in another manner now.
Before:
User::query()->joinRelation('posts.comments', [
'comments' => function ($join) { $join->type = 'left'; }
});
After:
User::query()
->joinRelation('posts')
->leftJoinThroughRelation('posts.comments');
This is more of a technical release.
The PHPStan level has been increased from 6 to 8, and the GitHub actions have been bumped from Node 16 to Node 20.
These changes help maintain the quality of each release.
Laravel 9 reached its end of life earlier this year. I have dropped support for L9, and added official support for Laravel 11.
With this comes dropping PHP 8.0, with the new minimum of PHP 8.1.
Laravel 8 reached its end of life earlier this year. I have dropped support for L8, and added future compatibility for the upcoming Laravel 11.
With this comes dropping PHP 7.3, with the new minimum of PHP 8.0.
PHP 8 offers better type-hinting, and overall works better with static analysis tooling. I have incorporated PHP Stan into the pipeline builds moving forward to offer better quality code for everyone.
Fixed #25.
Fixed aliasing error with morphOne relationship
Added Laravel 10.x support.
Dropped Laravel 7.x support.
Fixed strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated
Added Laravel 9 support.
Dropped Laravel 6.x support.
Example:
User::query()->joinRelation('posts.comments', [
'comments' => function ($join) { $join->type = 'left'; }
});
Example:
User::query()->joinRelation('posts.comments', [
function ($join) { $join->where('is_active', '=', 1); },
function ($join) { $join->where('comments.title', 'like', '%looking for something%'); }
});
See more in the readme.
Morph To example:
Image::query()->joinMorphRelation('imageable', Post::class);
// SQL: select * from "images" inner join "posts" on "posts"."id" = "images"."imageable_id" and "images"."imageable_type" = ?
Anonymous Join example:
$relation = Relation::noConstraints(function () {
return (new User)
->belongsTo(Country::class, 'country_name', 'name');
});
User::query()->joinRelation($relation);
// SQL: select * from "users" inner join "countries" on "countries"."name" = "users"."country_name"
See readme for more details.
While increasing code coverage, a couple of small bugs were found and fixed.
Includes query scope and soft deletion. Supported for Has One/Many Through and Belongs to Many relations.
Example:
// Adding pivot ("role_user") constraints for a "Belongs to Many" relation
User::query()->joinRelation('roles', function ($join, $pivot) {
$pivot->where('domain', '=', 'web');
});
Now that this package no longer supports Laravel 5.5, I can start using features available in Laravel 6.x.
One of these features is Mixins, which has allowed me to greatly reduce the footprint of this package.
This release changed a few things under the hood that should be transparent to most users.
>=6.20.12>=7.30.4>=8.22.1Laravel 5.5 is long past it's end of life, and is therefore no longer supported.
Similarly, PHP 7.1 is no longer supported.
Please use Laravel 6.x+ and PHP 7.2+ for the 2.x version of this package.
Fixed issue from v1.0.2 recursively so that nested where clauses within nested where clauses also work.
How can I help you explore Laravel packages today?