Hi everyone,
We are migrating a website to Statamic which has many features build using Laravel and eloquent. This brings up loads of query-challenges which we are not sure how to approach.
Let's say that users can pin articles for later. The articles are stored in stache (which we enjoy using) and the users/pins are stored in the DB using eloquent. We did manage to get to this point:
$pinnedEntries = \Statamic\Facades\Entry::query()
->where('collection', 'articles')
->whereIn('id', auth()->user()->pins()->pluck('collection_id')->toArray())
->where('published', true)
->get();
We have to manage way more advanced cases however. Like ordering articles based on which is pinned last. Or showing dates on which articles were pinned.
We did manage to get it working by querying the pins first and then querying every Entry individually. This feels really grows though. I was wondering if you guys could push us into a better direction.