Support all models
Sorry for the duplication of PRs here but I have reached out to the authors of both the previous PRs to try and combine efforts but have had no response from either.
As I indicated here I have taken the existing PR (#20) and added the rest of the models. I subsequently discovered the work that has since been opened in #41 and have added the additional blueprints and field sets work from it.
~~I have intentionally not included user groups and role as IMO they should be handled by Statamic core as part of the eloquent users setup.~~ Update: I've opened a PR in statamic/cms for this: https://github.com/statamic/cms/pull/5686
So to confirm this PR includes:
- [x] taxonomies
- [x] navigations
- [x] globals
- [x] collections
- [x] form submissions
- [x] asset containers
- [x] assets meta
- [x] blueprints
- [x] field sets
- [x] revisions
I have also refactored the code allow for devs to opt in via config to each 'model', I have ensured it uses the bound models, and I have written console import tasks to allow migration from file based data to eloquent.
Finally I have applied fixes from any open PRs and ensured they are included (with the exception of Jason's).
@jasonvarga I'd appreciate it if you could review this and let me know what you think.
@ryanmitchell great work! Would it be possible to save assets metadata in the database as well?
@FrittenKeeZ that had been done in #41 but I didn't carry it over as I'm not sure of why it would be wanted. I struggle to see why you would want it when you're already storing files on the filesystem and so can affect the .meta there. Can you help me understand the use case?
@ryanmitchell for me it's as much about separation of logic as it is about performance - instead of having to read double amount of files from a disk, all metadata can instead be fetched from the database when needed, instead of spending resources caching it all. Having it as an option though would be appropriate, as not everyone wants or needs this separation, but for someone like us with thousands of assets, it can affect performance a great deal.
@FrittenKeeZ no problem - as I said I wouldnt use it but I've added it there any way. I dont want to clutter the config too much so if you opt into asset containers then assets_meta is stored in the database too.
@ryanmitchell does your PR support revisions as well?
@FrittenKeeZ I've added support for it now, would be great if you could test it as I don't use this feature much so I may not have covered off everything.
Hi and thank you for creating this. Any eta to get this merged?
@Hesesses i wouldn’t expect it to be merged any time soon as I think there will be a significant testing and review process with changes made. You could pull it in as a composer patch in the mean time.
https://rias.be/blog/using-composer-patches
does that fixes collection reordering issue ?
does that fixes collection reordering issue ?
@enespolat24 combined with a PR that has been merged in statamic core in the last release yes.
thank you for your effort. looking forward to see this pr in action !
i tried this via composer patch but migrate gives error
i tried this via composer patch but migrate gives error
Can you give details of the error please?
hi . Sorry for the late reply.

@enespolat24 see if this change helps: https://github.com/statamic/eloquent-driver/pull/42/commits/c9f31d68a6d564b1247c4e17a21f8dba039b00bc
I came up with more errors 🙂 i tried to migrate using a freshly created db
@enespolat24 you should start with a clean site (or clear your migrations). That files doesn't exist in that folder in my PR - see: https://github.com/ryanmitchell/eloquent-driver/tree/fixes-to-all-models-pr/database/migrations
i have added this pull request but after i save anything in the cp it wont save it in the database
i have added this pull request but after i save anything in the cp it wont save it in the database
Can you provide an error trace so I can look into it please.
i dont get an error it just saves it to the file instead of the database
i saw that i cant publish the config file

@Oleafeon i've pushed some fixes here for the issues you were experiencing. Tested on a fresh install and all seems good to me.
You'll need to run:
php artisan vendor:publish --tag="statamic-eloquent-config"
then either:
php artisan vendor:publish --tag="statamic-eloquent-entries-table" or php artisan vendor:publish --tag="statamic-eloquent-entries-table-with-string-ids"
fixed thanks
I have a problem with creating / saving a collection entry that has enabled revisions. When i create a new entry or try to publish / unpublish i get the following error message:
local.ERROR: Call to a member function except() on array {"userId":1,"exception":"[object] (Error(code: 0): Call to a member function except() on array at [[PROJECT-LOCATION]]\\vendor\\statamic\\eloquent-driver\\src\\Revisions\\Revision.php:47)
When reloading the page after the error message is given the entry is actually created or published / unpublished
@RikHeynen odd, I didnt come across that in my testing. What Statamic version are you using? See if this fix helps?
@ryanmitchell I have tried, but get the following error in cp when added as patch:
Call to a member function handle() on array
@RikHeynen do you want to try debugging it and let me know what changes are required? Either that or i would need to know what version you are on to try and replicate it. Maybe you can provide access to a repo with your install?
@ryanmitchell Thanks for the help! The problem was at our side, so the problem seems to be fixed. Thanks again!
Hey @ryanmitchell i work together with @RikHeynen and get the same error:
Call to a member function handle() on array
This is my setup:
Statamic 3.3.3 Pro
Laravel 9.5.1
PHP 8.1.2
aerni/font-awesome 1.2.0
rias/statamic-link-it 2.2.3
statamic/eloquent-driver 0.2.0
statamic/seo-pro 3.1.0
The only thing i have different then your package is, i turned saving blueprints en fieldsets off in the config file cause we work with multiple people on the blueprint so we need them on github to merge them.

The error shows up after editing the settings of a collection in the cp, saving is okay but after we go to the collection page in the cp we see the error.
I also found an error when creating a navigation that said:
Call to a member function validateTree() on null
I have my log file for you here: https://pastebin.com/xYi4LsSi
@Oleafeon happy to help you debug it but I would need a test repository which recreates the issue so I can look into it. Alternatively if you debug it yourself and send any code changes required then I can include theme here.