Skip to content

Commit e1fd5c7

Browse files
committed
wip
1 parent 6659947 commit e1fd5c7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/PowerJoinClause.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,13 @@ public function __call($name, $arguments)
287287
return;
288288
}
289289

290-
if ($this->hasLaravelScopeAttribute($name) || method_exists($this->getModel(), 'scope'.ucfirst($name))) {
290+
if (method_exists($this->getModel(), 'scope'.ucfirst($name))) {
291+
$scope = 'scope'.ucfirst($name);
292+
293+
return $this->getModel()->{$scope}($this, ...$arguments);
294+
}
295+
296+
if ($this->hasLaravelScopeAttribute($name) && version_compare(app()->version(), '12.0.0', '>=')) {
291297
return $this->getModel()->callNamedScope($name, array_merge([$this], $arguments));
292298
}
293299

tests/LaravelScopeAttributeTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ class LaravelScopeAttributeTest extends TestCase
1414
*/
1515
public function it_can_use_laravel_scope_attribute_in_join_relationship_callback()
1616
{
17+
if (version_compare(app()->version(), '12.0.0', '<')) {
18+
$this->markTestSkipped('Laravel 12+ is required for this test');
19+
}
20+
1721
// Create test data
1822
$denmark = Country::create(['name' => 'Denmark', 'iso' => 'DK']);
1923
$usa = Country::create(['name' => 'United States', 'iso' => 'US']);

0 commit comments

Comments
 (0)