Releases: kirschbaum-development/eloquent-power-joins
Releases · kirschbaum-development/eloquent-power-joins
2.2.1
2.2.0
2.1.0 - Include trashed results
Added the ability to include trashed results by using the join callback:
UserProfile::joinRelationship('users', function ($join) {
$join->withTrashed();
});
```php
UserProfile::joinRelationship('users', function ($join) {
$join->onlyTrashed();
});2.0.0
- Laravel 8 support;
- PHP 8 support;
- A new trait that needs to be used in models;
- Namespace change which should not affect migrating users from 1.0;
- Automatically apply extra conditions from the relationship;
- Ability to order by using left joins;
- Changed the method signature for sorting;
- Changed the method signature for querying relationship existence;
- Bugfixes that were not possible by using the architecture from 1.0;
1.1.1
Added the ability to use table aliases
This release implemented the ability to use table aliases in the joins being made. It can be used in two ways.
Automatic
By calling the joinRelationshipUsingAlias method.
Post::joinRelationshipUsingAlias('category.parent')->get();This generates the following query:
SELECT "posts".* FROM "posts"
INNER JOIN "categories" AS "40071de3fbcf4e9399e166813abb7718" ON "posts"."category_id" = "40071de3fbcf4e9399e166813abb7718"."id"
INNER JOIN "categories" AS "ccecda2ab44b29ec904f7bdea7e5aa2e" ON "40071de3fbcf4e9399e166813abb7718"."parent_id" = "ccecda2ab44b29ec904f7bdea7e5aa2e"."id"By calling ->alias
You can also manually specify the table alias you want to use in the join callbacks.
Post::joinRelationship('category.parent', [
'parent' => function ($join) {
$join->as('category_parent');
},
])->get();This generates the following query:
SELECT "posts".* FROM "posts"
INNER JOIN "categories" ON "posts"."category_id" = "categories"."id"
INNER JOIN "categories" AS "category_parent" ON "categories"."parent_id" = "category_parent"."id"