Nested Relationships data not beeing saved

I'm currently working on a form to my Aluno model. Aluno belongs to Pessoa and Pessoa belongs to Endereco: Aluno->pessoa->endereco Even with relations defined, only Aluno and Pessoa are saved on create, for some reason, Endereco is not. All three are saved normally on Edit, i suppose that is because of belongsTo, but i'm not 100% sure and if is, is there a way to workaround? Here's the gist with the files. I can also create a test case if necessary. https://gist.github.com/JonatasBSM/17556af27f1d128c318010b62c574fe3
Gist
Aluno.php
GitHub Gist: instantly share code, notes, and snippets.
No description
3 Replies
LeandroFerreira
LeandroFerreira4mo ago
Shouldn't it be the inverse, enderecos has a pessoa_id? Group, Fieldset, Section layout are compatible with belongsTo, HasOne.. https://filamentphp.com/docs/3.x/panels/resources/relation-managers#layout-form-components---saving-form-fields-to-a-single-relationship
JonatasBraz
JonatasBrazOP4mo ago
But another entities could have a endereco, would i create a column to each entity on endereco table?
JonatasBraz
JonatasBrazOP4mo ago
i've created this simple repository to test the problem. https://github.com/JonatasBSM/belongsToTeste it has cidades resource, that tries to create cidade, estado and pais ($cidade->belongsTo->estado->belongsTo->pais), and pais resource, that tries to create pais, estado and cidade ($pais->hasOne->estado->hasOne->cidade). i know it should be hasMany in this cases, but was just to show the problem. when creating through cidades, it dont save pais and when creating through pais, it works as it should for tests, just clone the repository, composer install and create a database called belongstotest
GitHub
GitHub - JonatasBSM/belongsToTeste: Nested BelongsTo data not beein...
Nested BelongsTo data not beeing saved. Contribute to JonatasBSM/belongsToTeste development by creating an account on GitHub.
Want results from more Discord servers?
Add your server