eloquent-driver
eloquent-driver copied to clipboard
Undefined relationship after upgrade to statamic 3.3
When I'm visiting /api/collections/{collection}/entries I'm getting "Call to undefined relationship [author] on model [Statamic\Eloquent\Entries\UuidEntryModel]" after upgrade to statamic 3.3
After upgrading to Statamic 3.3 I'm experiencing the same where /entries
is throwing a RelationNotFoundException, stack trace is here:
https://flareapp.io/share/o7AKb1bm#F68
My setup is using the database instead files.
Have you tried the new PR branch to see if that would help? https://github.com/statamic/eloquent-driver/pull/42
I tried the new PR but it still doesen't work for me. But i found the commit that is causing the problem. https://github.com/statamic/cms/commit/ac70772990dccf560e10dcbdad6495dcc1518840#diff-919d52f8a749cfea24664e41c5b20b5a74117db74af777f9771f755b0b5fc0a5
In src/Http/Controllers/API/CollectionEntriesController.php
return app(EntryResource::class)::collection(
$this->filterSortAndPaginate($collection->queryEntries()->with($with))
);
If i remove the "->with($with)" like below it works
return app(EntryResource::class)::collection(
$this->filterSortAndPaginate($collection->queryEntries())
);
Hope that helps //Thanks
I also tried the PR, did not resolve it.
@Micke-Nilsson how are you storing users (eloquent or flat file)? I've pushed up a commit here that should work if its eloquent: https://github.com/statamic/eloquent-driver/pull/42/commits/ffb59d4a3bf28102a238271ba3a9e869f70c62cd
Im not happy with it as a long term solution as it doesnt account for when users might be using flat files but it should get over your issue.
Thank you for your response. I do store my users in eloquent so your workaround works for me. Thanks
Now that v1 has been released I think you can close this issue?
v1 solves the problem with the author relationship.
But if you for example create a news collection and a category taxonomie and then add the category to the news blueprint
you will still encounter the same problem if you don't manually add the relationship to the Statamic\Eloquent\Entries\EntryModel
@Micke-Nilsson can you pull together a sample repository that shows the issue so I can work on a fix?
Of course I can do that tomorrow
@ryanmitchell I agree with @Micke-Nilsson it's also not resolved in my case, if you want I can give you access to my repo, please share your gitlab username
@djmenkveld sure, I just signed up, ryanmitchell1
@ryanmitchell I've just invited you, my setup is a bit different, but you'll figure it out to run it. So, I'm stuck at Statamic v3.3.11 and did not upgrade after. I can't completely recall what I did 1.5 years ago, but I'm also referring from a collection > fieldset > taxonomy > blueprint, since I did not want to repeat myself.
@djmenkveld I'm in the project but cant see any code - are you sure my permissions are correct? Can you also ensure the data is included? It would be useful to get clear steps to reproduce the issue to minimise the time to reproduction.
@ryanmitchell I've upgraded your role from guest to developer. Once running, you should create a test post and you'll able to reproduce it.
@Micke-Nilsson any update on a sample repository?
Yes i have created a repository with instructions to reproduce the error https://github.com/Micke-Nilsson/statamic_issue
Wonderful, that was a great sample repository, thank you for the effort.
Fix here: https://github.com/statamic/eloquent-driver/pull/59
No problem, and thank you for your work
@Micke-Nilsson With help of @ryanmitchell I managed to resolve my issue, it works really good.
@ryanmitchell I have also verfied that it works, should i close this now?
No its ok, it will get closed when it merges.
Ok thanks a lot for the fix
Yes it looks like it
@Micke-Nilsson I ended up deleting the comment because I found out it was the same. Fixed manually for now, and awaiting the merge :)