# |
Jun 27th 2021, 18:19 |
cnizzardini |
So this works fine: |
# |
Jun 27th 2021, 18:18 |
cnizzardini |
I'm probably doing stuff wrong |
# |
Jun 27th 2021, 18:17 |
kevin.pfeifer |
I heavily use the new DI container, and got no problems. Can you explain your problem in more detail? |
# |
Jun 27th 2021, 18:16 |
cnizzardini |
Has anyone gotten auto wiring working with the new DI stuff? I am getting timeouts. |
# |
Jun 27th 2021, 15:33 |
kevin.pfeifer |
well thats something I totally overlooked when i read through the documentation :see_no_evil: ,:) |
# |
Jun 27th 2021, 15:20 |
ndm |
@alamnaryab Configure a custom finder for the related identifier's ORM Resolver, you can then contain your associations in that finder. https://stackoverflow.com/questions/63057543/cakephp-4-1-user-entity-as-authorization-identity-associated-fields/63061706#63061706 |
# |
Jun 27th 2021, 10:55 |
alamnaryab |
I think it is like below but I could not found any documentation or example ``` $result = $this->Authentication->setIdentity($userWithContainedModels); $result = $result->getResult();``` |
# |
Jun 27th 2021, 10:41 |
kevin.pfeifer |
``` $result = $this->Authentication->getResult(); if($result){ $user = $result->getData(); }``` the $user is an entity which has its own fields but does not contain any fields from other (containing) models (like roles) How to tell the authentication service that the resulting user entity should contain other models I can’t tell you right now but I am curious too :thinking_face: |
# |
Jun 26th 2021, 23:02 |
alamnaryab |
`$result = $this->Authentication->getResult();` `$result` has a protected property `_data` which has logged in user record. I am not able to find documentation how to append its protect property `_data` |
# |
Jun 26th 2021, 22:59 |
alamnaryab |
Good Morning I am using cakephp 4 Authentication plugin https://book.cakephp.org/4/en/tutorials-and-examples/cms/authentication.html on successful login I also want to get roles from database for that user. how can I do? |
# |
Jun 26th 2021, 18:52 |
cnizzardini |
nevermind, it comes from the league/container, but is not present in the cakephp container interface so phpstorm doesn't know |
# |
Jun 26th 2021, 18:49 |
cnizzardini |
Documentation indicates there is a `$container->share` method, but I don't see one https://book.cakephp.org/4/en/development/dependency-injection.html#adding-shared-services |
# |
Jun 26th 2021, 15:51 |
mokiwaa |
Thk you |
# |
Jun 26th 2021, 15:50 |
mokiwaa |
I will check again the logs file and debugkit sql generated ... |
# |
Jun 26th 2021, 15:44 |
kevin.pfeifer |
well a hasMany and hasOne aren't that different from a database structure point of view. I haven't used the proffer plugin till now but I guess this shouldn't be the problem. Either way do you have something in your logs directory that could lead to you to some problem? Or maybe check the DebugKit generated sql when showing the file(s) if everything looks like you expect it |
# |
Jun 26th 2021, 15:38 |
mokiwaa |
but no luck |
# |
Jun 26th 2021, 15:38 |
mokiwaa |
and echo $this->Form->control('brand_logo', ['label'=>'Logo', 'type'=>'file']); |
# |
Jun 26th 2021, 15:38 |
mokiwaa |
I have tried to use echo $this->Form->control('brand_logos', ['label'=>'Logo', 'type'=>'file']); |
# |
Jun 26th 2021, 15:38 |
mokiwaa |
in the form |
# |
Jun 26th 2021, 15:37 |
mokiwaa |
the image get upload |
# |
Jun 26th 2021, 15:37 |
mokiwaa |
but if I use hasMany |
# |
Jun 26th 2021, 15:37 |
mokiwaa |
I cant make it work |
# |
Jun 26th 2021, 15:37 |
mokiwaa |
with hasOne association |
# |
Jun 26th 2021, 15:37 |
mokiwaa |
I have a problem with the proffer plugin |
# |
Jun 26th 2021, 15:36 |
kevin.pfeifer |
just ask :) |
# |
Jun 26th 2021, 15:35 |
mokiwaa |
:) |
# |
Jun 26th 2021, 15:35 |
mokiwaa |
still |
# |
Jun 26th 2021, 15:35 |
mokiwaa |
stile there? |
# |
Jun 26th 2021, 15:16 |
kevin.pfeifer |
yes |
# |
Jun 26th 2021, 15:10 |
mokiwaa |
someone online? |
# |
Jun 26th 2021, 15:09 |
mokiwaa |
Hi |
# |
Jun 26th 2021, 14:33 |
kevin.pfeifer |
from a quick read through I would also say that this data should be present in the junction table between the 2 main tables. And only the junction table has the foreign keys for the 2 main tables - therefore as Zuluru already said a `belongsToMany` |
# |
Jun 26th 2021, 14:19 |
greg138 |
It sounds like this should be a `belongsToMany` association for both models, meaning that Answers is the join table. Am I missing something? |
# |
Jun 26th 2021, 13:48 |
slackebot |
Recommendation to the Answer and landed on this current solution. What do you guys and gals think? |
# |
Jun 26th 2021, 13:48 |
slackebot |
which has foreign keys for Assessment and Recommendation plus the extra data. When I create an Assessment record I use beforeMarshal to create an Answer for each Recommendation that was selected for the Assessment. While this works, it seems a little 'hacky'. Can anyone see a better way to achieve this outcome? I had originally tried with addition join table data but I couldn't figure out a way to join both the Assessment and |
# |
Jun 26th 2021, 13:48 |
tomrwaller |
Hey everyone, just wanted to ask for some advice about how I'm currently doing my associations and whether anyone thinks there is a better way. I currently have Assessments and Recommendations. An Assessment has many Recommendations and a Recommendation can belong to many Assessments. I want to store answers to Recommendations for each Assessment. Just a couple of fields maybe up to 10. At the moment I have a Answers model |
# |
Jun 25th 2021, 17:03 |
ricmelero |
Thank @admad and @kevin.pfeifer! |
# |
Jun 25th 2021, 17:01 |
ricmelero |
never mind, I got it working now, later this year I expect to have fewer work and I may take a look into routing, I have noticed a few cases that are weird or may be improved (like redirecting to array styles named routes) and I'll loved to help... |
# |
Jun 25th 2021, 16:56 |
steinkel |
we usually rely on any of the https://github.com/CakeDC/cakephp-api/tree/master/src/Service/Auth/Authenticate for API based applications |
# |
Jun 25th 2021, 16:56 |
nick.vanderwoude |
@steinkel I did see that. Is it working? |
# |
Jun 25th 2021, 16:55 |
steinkel |
@nick.vanderwoude we did some work time ago to provide a specific endpoint for ajax login here https://github.com/CakeDC/users/pull/789 |