orchidsoftware / orchidsoftware/platform
HasOne relationship generates a loop
@tabuna is already working on this.
Since Aug 17, 2021.
- Dominant language
- PHP
- Stars
- 4.8k
- Forks
- 663
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 7
Description
Describe the bug
When using the attachments with the hasOne relationship, I somehow generate a loop. As soon as I've remove the relationship the admin panel works again but I cannot retrieve the attachments anymore.
This only affects the "create" edit screen. If I edit an existing record, it works as usual.
To Reproduce
Steps to reproduce the behavior:
public function hero()
{
return $this->hasOne(Attachment::class, foreignKey: 'id', localKey: 'hero')->withDefault();
}
Expected behavior
It should be possible to use the hasOne relationship even without an existing record.
Screenshots

https://flareapp.io/share/Bm03adE5#F257
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Server (please complete the following information):
- Platfrom Version: 10.12.2
- Laravel Version: 8+
- PHP Version: 8.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.