Skip to content

Commit 136efda

Browse files
authored
Merge pull request #61 from Lomkit/GautierDele-patch-1
Update 3.relationships.md
2 parents e6d04b1 + 7859954 commit 136efda

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

content/3.resources/3.relationships.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,15 @@ public function commentable(): MorphTo
167167

168168
public function post(): MorphTo
169169
{
170-
return $this->commentable()->whereHas('comments', function (Builder $query) {
171-
$query->where('comments.commentable_type', Post::class);
170+
return $this->morphTo('post', 'commentable_type', 'commentable_id')->whereHas('comment', function (Builder $query) {
171+
$query->where('commentable_type', Post::class);
172172
});
173173
}
174174

175175
public function video(): MorphTo
176176
{
177-
return $this->commentable()->whereHas('comments', function (Builder $query) {
178-
$query->where('comments.commentable_type', Video::class);
177+
return $this->morphTo('video', 'commentable_type', 'commentable_id')->whereHas('comment', function (Builder $query) {
178+
$query->where('commentable_type', Video::class);
179179
});
180180
}
181181
```

0 commit comments

Comments
 (0)