-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from tsterker/fix-has-many-through
fix: HasManyThrough and HasOneThrough not working
- Loading branch information
Showing
7 changed files
with
144 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Parental\Tests\Models; | ||
|
||
use Parental\HasParent; | ||
|
||
class ChildNode extends Node | ||
{ | ||
use HasParent; | ||
|
||
protected $guarded = []; | ||
|
||
public function parent() | ||
{ | ||
return $this->hasOneThrough( | ||
ParentNode::class, | ||
NodeEdge::class, | ||
'child_node_id', | ||
'id', | ||
'id', | ||
'parent_node_id', | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Parental\Tests\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Parental\HasChildren; | ||
|
||
class Node extends Model | ||
{ | ||
use HasChildren; | ||
|
||
protected $guarded = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Parental\Tests\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class NodeEdge extends Model | ||
{ | ||
protected $guarded = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Parental\Tests\Models; | ||
|
||
use Parental\HasParent; | ||
|
||
class ParentNode extends Node | ||
{ | ||
use HasParent; | ||
|
||
protected $guarded = []; | ||
|
||
public function children() | ||
{ | ||
return $this->hasManyThrough( | ||
ChildNode::class, | ||
NodeEdge::class, | ||
'parent_node_id', | ||
'id', | ||
'id', | ||
'child_node_id', | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters