Closed j3ll3yfi5h closed 3 months ago
The whereCollection
and whereInCollection
methods do still exist on the Entry
repository/facade.
However, by the looks of those error messages, you're trying to use them on the query builder (where they don't exist)?
@duncanmcclean Ah interesting, you're right!
Can you maybe explain to me, what is the difference? Most examples on this page https://statamic.dev/repositories/entry-repository are about using the methods in query builders, right? Or am I completely confused?
So, the methods here are the methods on the Entry
facade (& the repository, which is what the facade hits when you call it):
The query
method will give you a "query builder" instance. The query builder is another object which lets you query & order entries. It's what lets you do filtering like ->where('foo', 'bar')
.
The query builder has a different set of methods to those on the repository.
For example:
Entry::query() // the query method makes a "query builder"
->where('collection', 'pages') // adds a "condition" to the query, filtering entries to those where the collection = pages
->where('foo', 'bar') // adds another "condition" to the query, filtering entries to those where foo = bar
->get() // actually executes the query to get the results. the get method returns a Laravel Collection instance
->map() // this map method exists on the Laravel Collection instance (which you can find out more about here: https://laravel.com/docs/master/collections)
Does that help?
@duncanmcclean Aha, I understand. Thank you very much for your explanations!
Methods are not available anymore and throw errors:
Call to undefined method Statamic\Stache\Query\EntryQueryBuilder::whereCollection()
Call to undefined method Statamic\Stache\Query\EntryQueryBuilder::whereInCollection()