I have very simple relation, user has many organizations and organization has many users (nothing unusual). But when I want to fetch:
dump($result->user->organizations);
Column 'organization_id' doesn't belong to the model or alias 'App\Model\UserHasOrganization', when executing: SELECT [App\Model\Organization].* FROM [App\Model\Organization] INNER JOIN [App\Model\UserHasOrganization] ON [App\Model\UserHasOrganization].[organization_id] = [App\Model\Organization].[id] WHERE [App\Model\UserHasOrganization].[user_id] = :APR0:
I recognize that when I replace columns mapping, it works:
public function columnMap()
{
return [
//...
'organizationId' => 'organization_id'
];
}
But now second side is spoiled:
dump($result->organization->users);
Is a simple way to recognize a relation side and use array_flip to set columnMap dynamic?