statamic / eloquent-driver

Provides support for storing your Statamic data in a database, rather than flat files.
https://statamic.dev/tips/storing-content-in-a-database
MIT License
104 stars 71 forks source link

Fix querying statuses #279

Closed duncanmcclean closed 2 months ago

duncanmcclean commented 2 months ago

This pull request fixes an issue I ran into this morning when using the REST API alongside the Eloquent Driver.

Essentially, when the REST API queries to get entries, it filters for entries where status is published. However, when using the Eloquent Driver, no entries were being returned.

I've fixed this issue by copying over the recent changes around entry statuses to the Eloquent Driver (related: #9317).

The implementation is mostly the same as it is in Core. However, the main difference is the fact the Eloquent Driver's query builder doesn't maintain a $collections property to track the queried collection, instead we're just using $this->wheres()

To Do

jasonvarga commented 2 months ago

When building the status stuff in core, I was thinking that Eloquent driver extended that. I didn't realize we would need to copy over whereStatus and all the related methods.

I'm making a PR into core to extract it into a trait that'll make this PR much leaner.