Replies: 1 comment
-
I was thinking that in all cases the pivot table will always be included in query, so why not deal with it this way: \\App\Models\Tag
public function scopeWherePublished(Builder $query){
return $query->where('taggables.published', true);
} and it works as expected, but my question remains, is this the right way to do it? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I've the following database structure, almost identical to Laravel docs:
and here is my models:
The problem
I'm trying to scope pivot table inside Tags model but no way I can get it to work, the example provided in Laravel docs doesn't work.
this example is based on the docs, it fires the following exception:
call to undefined method App\Models\Post::taggable()
but if I wrote it this way it works:
but this is not how it should work, I should be able to query using pivot table not the main.
I've tried many other things and searched, but no succeed, any help/ideas really appreciated.
Beta Was this translation helpful? Give feedback.
All reactions