cms icon indicating copy to clipboard operation
cms copied to clipboard

Compability for EloquentQueryBuilder

Open ryanmitchell opened this issue 2 years ago • 8 comments

Just noticed this will be needed as part of the Eloquent package models PR seeing as we inherit from this class

~~Edit: moved to draft status as we'll need to support where nested and arrays~~

ryanmitchell avatar Apr 15 '22 13:04 ryanmitchell

This should now be complete with everything needed for the Eloquent all models PR

ryanmitchell avatar Apr 19 '22 12:04 ryanmitchell

@ryanmitchell I've provided fixes here: ryanmitchell/cms#1

FrittenKeeZ avatar Jul 13 '22 13:07 FrittenKeeZ

@ryanmitchell can you merge the latest changes of 3.3 into this?

FrittenKeeZ avatar Jul 14 '22 08:07 FrittenKeeZ

@jasonvarga I'm struggling to figure out where to add @blueprint as an option for collection templates, since it's a lot more difficult to manually change when storing collections in the database.

FrittenKeeZ avatar Jul 14 '22 10:07 FrittenKeeZ

@FrittenKeeZ We'd need to adjust the fieldtype used to select a template on the collection edit page to either allow text input so you can type @blueprint, or somehow add the @blueprint option. https://github.com/statamic/cms/blob/b7de86426e777ac44e1baba35b9b7869ea13b2a7/src/Http/Controllers/CP/Collections/CollectionsController.php#L427-L432

But that doesn't seem relevant to this PR.

jasonvarga avatar Jul 14 '22 14:07 jasonvarga

@jasonvarga yeah I kinda tunnel visioned and wrote it here, before I realized it's not strictly related to Eloquent. Having @blueprint as a selectable option would be ideal imo, since it's tightly bound to specific logic anyway.

FrittenKeeZ avatar Jul 14 '22 14:07 FrittenKeeZ

@jasonvarga I would love for this to get merged soon!

FrittenKeeZ avatar Aug 01 '22 08:08 FrittenKeeZ

@ryanmitchell for some reason bindings don't work when using the Eloquent contract as type hint, which makes absolutely no sense, so it should just be reverted to the actual class instead.

Statamic\Query\EloquentQueryBuilder::__construct(): Argument #1 ($builder) must be of type Illuminate\Contracts\Database\Eloquent\Builder, Illuminate\Database\Eloquent\Builder given, called in /Users/FSA/Projects/statamic/eloquent-driver/src/ServiceProvider.php on line 188

PR: https://github.com/ryanmitchell/cms/pull/3

FrittenKeeZ avatar Aug 09 '22 08:08 FrittenKeeZ

I've been doing a bit of work on the eloquent driver over this week and it strikes me that this class might be better being bundled as part of that, as it allows for changes to be made alongside the driver requirements rather than needing to sync releases. What do you feel the benefit is of keeping it as part of core?

ryanmitchell avatar Aug 12 '22 07:08 ryanmitchell

We have the eloquent user stuff in the core, which needs it.

jasonvarga avatar Aug 12 '22 18:08 jasonvarga

Yeah I remembered that after I asked. Friday brain

ryanmitchell avatar Aug 12 '22 18:08 ryanmitchell

Thanks for the suggestion. I've pushed an update with that, which allows toSql, dd and count to be removed.

However, when/unless/tap need to stay as otherwise the subquery gets an instance of illuminate's builder, not statamics, which means that the where clauses etc dont pass through the extra logic required.

ryanmitchell avatar Aug 15 '22 19:08 ryanmitchell

However, when/unless/tap need to stay as otherwise the subquery gets an instance of illuminate's builder, not statamics, which means that the where clauses etc dont pass through the extra logic required.

Cool, my bad. 👍

jasonvarga avatar Aug 15 '22 19:08 jasonvarga