Closed piljac1 closed 1 year ago
Any reason why you aren't using https://github.com/statamic/eloquent-driver instead of rolling your own?
To be honest, no reason. I'm not that experienced with Statamic and just looked around the Statamic docs and searched for both "eloquent" and "database" and other than the Tips & Tricks articles like the one I stated, the Eloquent driver isn't stated anywhere. I assumed the eloquent-driver package was used by the CMS internally and that the Tips & Tricks articles leveraged what that driver added to the core. Guess I was wrong.
Yeah the docs could maybe be a bit more clear that the package exists. Give it a go, I think it'll solve both your issues.
Thanks, I'll try it out. Any limitation I should be aware of? Because I also want to have a standard relational database structure for data heavy tasks. Basically, does this driver function properly if I intend to use Runway for the heavy lifting and standard entries for stuff like pages and articles?
Yes it's a drop in replacement for flat files at this point.
Can you close this issue?
Environment
Laravel Version: 9.48.0 PHP Version: 8.1.12 Composer Version: 2.1.6 Database: MySql 8.0.31 Statamic Version: 3.3.65 PRO
The issue
After following the "Storing Entries in a Database" docs (apart from the fact I use an auto-increment ID), I encountered an issue where creating a related (localized) entry would "work" as it is stored in the database, but would not be detected by Statamic (still showing a red dot by the other site's version of the entry). If you try to create the same related entry again, it creates a duplicate in the database and still is undetected by Statamic.
After debugging, I found out that both
descendants
anddetachLocalizations
(from theStatamic\Entries\Entry
class) refer toorigin
in their querieswhere
clauses instead oforigin_id
as specified in the suggested "Storing Entries in a Database" docsentries
table migration. When replacingorigin
withorigin_id
, it seems to behave properly, but it is not as simple as that, since changing this could be breaking for other people setups.Reproduction repo
P.S. My "hotfix" is applied in this repo, so if you want to see the actual bug, search for the
descendants
anddetachLocalizations
methods inapp/Eloquent/Entries/Entry.php
and comment them.https://github.com/piljac1/statamic-eloquent-issues