Open ronlobo opened 11 years ago
Hi, I am interested in this too. Would hate to have to go back to the original relationships.
Sorry for the freaking long delay, men! Short answer: I have no clue. Long answer: I'll investigate what this method does and see how I could integrate it in the relationship array!
This was added by myself 2 months ago and has lived in documentation ever since. Simply add the named key pivotKeys
to your relationship:
public static $relationsData = array(
'attributes' => array(
'belongsToMany',
'Attribute',
'table' => 'collections_have_attributes',
'pivotKeys' => array('foo', 'bar')
)
);
@igorsantos07 it's safe to close this issue.
Hello @dalabarge and @igorsantos07 , sorry to post in this old topic, but I felt it was better then openning a new one.
I'm having some issues with the use of pivot relations in Ardent.
My pivot relation using Elloquent works fine, but when I try using the Ardent relations I keep getting "Undefined Columns" errors.
I created my relation as follow
public static $relationsData = array(
'pessoas' => array(
'belongsToMany',
'Pessoa',
'table' => 'indicadorpessoa',
'pivoteKeys' => array('ref_pessoa', 'ref_indicador')
)
);
But when I try to get the relations I keep getting the following error
SQLSTATE[42703]: Undefined column: 7 ERRO: coluna indicadorpessoa.pessoa_id não existe LINE 1: ...r join "indicadorpessoa" on "pessoa"."pessoaid" = "indicador... ^ (SQL: select *, "indicadorpessoa"."indicador_id" as "pivot_indicador_id", "indicadorpessoa"."pessoa_id" as "pivot_pessoa_id", "indicadorpessoa"."ref_pessoa" as "pivot_ref_pessoa", "indicadorpessoa"."ref_indicador" as "pivot_ref_indicador" from "pessoa" inner join "indicadorpessoa" on "pessoa"."pessoaid" = "indicadorpessoa"."pessoa_id" where "indicadorpessoa"."indicador_id" = 6)
Ardent is trying to use the default keys 'pessoa_id' and 'indicador_id' along with the ones I'm passing ('ref_pessoa' and 'ref_indicador').
Any insight? Am I doing something wrong? The exacly same relation works fine with elloquent, I'll keep using it until I can figure whats wrong.
Sorry about grammar mistakes.
@lvian I'm no longer maintaining this commit nor Ardent in general as I've transitioned away from using it. Instead I would recommend esensi/model
if your project supports PHP 5.4. It has support for this sort of relationship setup as a trait and also with validation among other things.
Hello @lvian. Unfortunately I have little to no knowledge of Laravel so I'm unable to help you on this matter :( But later this month I'll be looking for new maintainers to help us on this :)
And it's very good to know from this channel that the original developer have permanently abandoned the project in place of another one and never ever left feedback on why or suggestions of moving out as well. Didn't even bother on changing the repository ownership. That's what I call caring for your equals lol On 8 Oct 2014 19:19, "Daniel LaBarge" notifications@github.com wrote:
@lvian https://github.com/lvian I'm no longer maintaining this commit nor Ardent in general as I've transitioned away from using it. Instead I would recommend esensi/model https://github.com/esensi/model if your project supports PHP 5.4. It has support for this sort of relationship setup as a trait and also with validation among other things.
— Reply to this email directly or view it on GitHub https://github.com/laravelbook/ardent/issues/92#issuecomment-58437315.
@igorsantos07 was that last paragraph directed at me? I sure hope not. I'm neither the original developer nor ever was a maintainer – I tried to contribute but PRs remain unmerged and issues remain outstanding. I don't blame the maintainers for that so let's not send out the vibe that contributors who likewise owe this package nor it's user base anything are to blame. No one needs more drama.
I do hope that you find new maintainers later this month and will do my best to point your way anyone I can who is looking for an OS project to help with. Good luck and happy coding! :)
Thanks for your kindness. This is the second time I mis-guess GitHub usernames through email. I'll stop replying issues though my inbox. Sorry for that mistake :( (Obviously I mistook you for the original repository's owner)
Cheers! On 9 Oct 2014 11:04, "Daniel LaBarge" notifications@github.com wrote:
@igorsantos07 https://github.com/igorsantos07 was that last paragraph directed at me? I sure hope not. I'm neither the origin developer nor ever was a maintainer – I tried to contribute but PRs remain unmerged and issues remain outstanding. I don't blame the maintainers for that so let's not send out the vibe that contributors who likewise owe this package nor it's user base anything are to blame. No one needs more drama.
I do hope that you find new maintainers later this month and will do my best to point your way anyone I can who is looking for an OS project to help with. Good luck and happy coding! :)
— Reply to this email directly or view it on GitHub https://github.com/laravelbook/ardent/issues/92#issuecomment-58513864.
Hi @lvian,
It might be extremely late and I apologize for necro-ing the issue, but if you change your code from pivoteKeys
to pivotKeys
it should work fine.
@mihaiscurtucb nice catch. I updated my snippet to reflect that for any other lost soul winding up on this issue. Sometimes the solutions are just starring us in the face! :+1:
Hi,
can somebody explain how https://github.com/laravelbook/ardent#cleaner-definition-of-relationships--since-20 works with pivot?
e.g. eloquent model relation function:
now with ardent:
where do I add the withPivot('value')?
Thanks in advance!