Skip to content

Commit e5024ae

Browse files
bohehekitloong
andauthored
Laravel-12 (#10)
* VUP pkg to support Laravel-12 * Feature/laravel12 (#9) VUP for Laravel-12 * update readme --------- Co-authored-by: Kit Loong <[email protected]>
1 parent e6e36d4 commit e5024ae

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ composer require kitloong/eloquent-power-joins-with-compoships
2222

2323
## Usage
2424

25+
### v2 breaking change
26+
In v2, the `use PowerJoins` is not available because [Eloquent Power Joins](https://github.com/kirschbaum-development/eloquent-power-joins) has moved the trait `PowerJoins` to `JoinRelationship` Mixin.
27+
2528
To implement join with composite key
2629

2730
```sql
@@ -36,7 +39,7 @@ use Kirschbaum\PowerJoins\PowerJoins;
3639

3740
class User extends Model
3841
{
39-
use PowerJoins;
42+
use PowerJoins; // this is unavailable in v2
4043
use Compoships;
4144

4245
public function posts()

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
}
1717
],
1818
"require": {
19-
"kirschbaum-development/eloquent-power-joins": "^2.4",
19+
"kirschbaum-development/eloquent-power-joins": "^4.2",
2020
"awobaz/compoships": "^2.1"
2121
},
2222
"require-dev": {
23-
"orchestra/testbench": "^4.0|^5.0|^6.0|^7.0|^8.0",
23+
"orchestra/testbench": "^4.0|^5.0|^6.0|^7.0|^8.0|^9.0|^10.0",
2424
"laravel/legacy-factories": "^1.1",
2525
"squizlabs/php_codesniffer": "^3.6"
2626
},

src/Mixins/RelationshipsExtraMethods.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace KitLoong\PowerJoins\Mixins;
44

55
use Kirschbaum\PowerJoins\Mixins\RelationshipsExtraMethods as Base;
6+
use Kirschbaum\PowerJoins\StaticCache;
67

78
/**
89
* @method getModel
@@ -16,7 +17,7 @@ protected function performJoinForEloquentPowerJoinsForBelongsTo()
1617
{
1718
return function ($query, $joinType, $callback = null, $alias = null, bool $disableExtraConditions = false) {
1819
$joinedTable = $this->query->getModel()->getTable();
19-
$parentTable = $this->getTableOrAliasForModel($this->parent, $this->parent->getTable());
20+
$parentTable = StaticCache::getTableOrAliasForModel($this->parent, $this->parent->getTable());
2021

2122
$query->{$joinType}($joinedTable, function ($join) use ($callback, $joinedTable, $parentTable, $alias, $disableExtraConditions) {
2223
if ($alias) {
@@ -61,7 +62,7 @@ protected function performJoinForEloquentPowerJoinsForHasMany()
6162
{
6263
return function ($builder, $joinType, $callback = null, $alias = null, bool $disableExtraConditions = false) {
6364
$joinedTable = $alias ?: $this->query->getModel()->getTable();
64-
$parentTable = $this->getTableOrAliasForModel($this->parent, $this->parent->getTable());
65+
$parentTable = StaticCache::getTableOrAliasForModel($this->parent, $this->parent->getTable());
6566

6667
$builder->{$joinType}($this->query->getModel()->getTable(), function ($join) use ($callback, $joinedTable, $parentTable, $alias, $disableExtraConditions) {
6768
if ($alias) {

0 commit comments

Comments
 (0)