Closed Dragon001-github closed 1 week ago
Would you be able to put together a test repo that contains your specific setup that I could look at? That would help to answer your question better. Thanks!
Hello, I apologize for the long reply.
It's actually quite simple.
I installed pure Statamic, configured the Eloquent driver to store Entry in the database.
2 entities were created through Statamic admin. 2 random fields were merged together. For us it was: Exhibits and Champions.
Communication via Provider was set up.
Relate::manyToMany( 'exhibits.champions', 'champions.exhibits' )->allowDelete(false);
After that when saving everything works fine, when deleting it does not work.
When you say deleting does not work, are you saying deleting itself does not work, or that nothing happens with the relationships?
When you delete a champion from an exhibit, for example, the exhibit remains in the champion.
We have the same issue. What I have done to test:
Installed a new Statamic and created 2 collections, books and authors with a one to Many relationship. With the flat file system it all works great. I have done exactly the same with de default eloquent driver and then it does not updates the relationship right.
@JohnathonKoster How can I help you to fix this, which info do you need? Because we want to push the new collections to productions, but before that, we want that it works as is should work.
@GertTimmerman Thanks for the comment! If you have time, would it be possible to put together a small repo that replicates this using the Eloquent driver and SQLite? This really helps to accelerate my side of things once I get into it
@GertTimmerman Thanks for the comment! If you have time, would it be possible to put together a small repo that replicates this using the Eloquent driver and SQLite? This really helps to accelerate my side of things once I get into it
I have created it here: https://github.com/GertTimmerman/statamic-entry-relationshop-db
When you change the author of a book, all the relations will mess up
I also think I have the solution, but I not so into the code that i am sure. If you change row /src/Processors/Concerns/GetFieldValue.php:19
to return $entry[$fieldName] ?? $default;
So it look like this:
protected function getPristineValue($fieldName, $entry, $default = null)
{
if ($entry instanceof User || (method_exists($entry, 'model') && method_exists($entry, 'toModel'))) {
$entry = $entry->model();
}
if ($entry instanceof Model) {
return $entry[$fieldName] ?? $default;
}
return $this->getFieldValue($fieldName, $entry, $default);
}
I think that will solve it. And I say think, because the first times it didn't work, and then suddenly it works how it should work
Thanks for the repo! I'll take a look this week and get something going for this
Improved DB support with 2.2.1
Hello, we have encountered a problem while working with a database.
We have created two entities and linked them together as specified in the instructions.
When adding, everything works fine, but when we delete an item from either entity, it remains in the other one.
Looking at the code,we found that when we pull out the old data:
The function inside that tries to get the data out of the model tries to find it at the same level when the data in the standard model lies in data.
Is this an actual problem or is this us not handling the model correctly?
We are using the standard driver https://github.com/statamic/eloquent-driver