# |
Oct 6th 2016, 17:15 |
hmic |
Leidenfrost, what i said will work on 2.2. |
# |
Oct 6th 2016, 17:15 |
hmic |
Unfaiir, http://book.cakephp.org/3.0/en/migrations.html |
# |
Oct 6th 2016, 17:14 |
hmic |
and there is no excuse eighter! |
# |
Oct 6th 2016, 17:14 |
hmic |
Leidenfrost, first: there is no reason to not upgrade this ancient version of cake to a more decent 2.x release! |
# |
Oct 6th 2016, 17:14 |
Leidenfrost |
Sorry, Cake 2.2 |
# |
Oct 6th 2016, 17:13 |
hmic |
there is a migrations shell |
# |
Oct 6th 2016, 17:13 |
hmic |
Unfaiir, there is. its callled migrations |
# |
Oct 6th 2016, 17:13 |
Unfaiir |
In cakephp 3, do we still build the tables manually or is there some kind of database migration like ASP.NET and Laravel that builds and changes the tables automatically? |
# |
Oct 6th 2016, 17:11 |
hmic |
you do need 2: belongsTo Manager and hasMany Managedusers, as nemmons said |
# |
Oct 6th 2016, 17:11 |
nemmons |
sorry ignore that |
# |
Oct 6th 2016, 17:11 |
hmic |
and it should be a belongsto as i said |
# |
Oct 6th 2016, 17:11 |
hmic |
Leidenfrost, sure you did not missmatch the foreignkey and associationforeignkeys? |
# |
Oct 6th 2016, 17:11 |
nemmons |
shouldn't that be HasMany? |
# |
Oct 6th 2016, 17:09 |
Leidenfrost |
hmic: not a good idea, but sadly I can't change the schema. I tried this: http://pastebin.com/UW5X4ELt , but it didn't work |
# |
Oct 6th 2016, 17:02 |
hmic |
the associations just need to be uniquely named. you still can name an association after the model it is in. - but as i said, not a good idea probably |
# |
Oct 6th 2016, 17:01 |
nemmons |
oh, that's good to know |
# |
Oct 6th 2016, 17:01 |
hmic |
it can actually. still its not a good idea probably ,-) |
# |
Oct 6th 2016, 17:00 |
nemmons |
@hmic can User hasMany User without having to alias it to a different name like 'ManagedUsers'? |
# |
Oct 6th 2016, 16:58 |
hmic |
leidenfrost: you will need to: belongsTo "Manager" and hasMany "User" |
# |
Oct 6th 2016, 16:57 |
nemmons |
which version of cake? |
# |
Oct 6th 2016, 16:56 |
Leidenfrost |
I'm trying to create a model relationship with itself. This is the scheme, more or less: Model 'User' has a "manager_id", which link to the column 'id' of User. That manager-type 'User' has 'manager_id' null. But I can't figure out the relationship in the cake model. |
# |
Oct 6th 2016, 16:54 |
Leidenfrost |
Hi all. I |
# |
Oct 6th 2016, 16:45 |
hmic |
ok. just wanted to be sure you are not digging on the wrong side .p still: please let me know how you solved it |
# |
Oct 6th 2016, 16:44 |
nemmons |
I understand that. I was just making a side comment that it would be nice to better understand the whole startup sequence. I agree that what i need to do to solve my particular problem here is what you're suggesting |
# |
Oct 6th 2016, 16:43 |
hmic |
you cannot fix the initial problem - ever. as its "you need a user to auth a user", so this is not resolvable in the order the controller invokes things |
# |
Oct 6th 2016, 16:43 |
hmic |
nemmons: you dont need to. you do need to find out how to attach/activate footprint later in the process |
# |
Oct 6th 2016, 16:41 |
nemmons |
I really need to take some time and read through all this code so i can understand the controller startup sequence. It's all magic to me. |
# |
Oct 6th 2016, 16:41 |
nemmons |
Unfortunately that's not working. I believe it's because it's the job of the FootprintAwareTrait to attach the FootprintListener to the table, so just adding the behavior in the beforeFilter isn't enough. But this gives me an avenue to explore so i appreciate you pointing me in the right direction |
# |
Oct 6th 2016, 16:25 |
hmic |
let me know how its going |
# |
Oct 6th 2016, 16:25 |
hmic |
beforeFilter *callback*, not *event* is late enough in the process to have the user authenticated already *imho* - just debug($this->Auth->user()) from there to verify. |
# |
Oct 6th 2016, 16:24 |
hmic |
my idea - not tested - basically: AppController::beforeFilter() { TableRegistry->get('User')->attachBehavior('Footprint'); } |
# |
Oct 6th 2016, 16:23 |
hmic |
if not, just use beforeFilter (callback!) to attach it |
# |
Oct 6th 2016, 16:23 |
nemmons |
Okay, that all makes sense, thank you. |
# |
Oct 6th 2016, 16:23 |
hmic |
there does even exist a proper event in the auth class, afterAuthenticate, i think |
# |
Oct 6th 2016, 16:23 |
hmic |
hint: you can get the usertable from the tableregistry and manually attach the footprint behavior after the user has been authenticated |
# |
Oct 6th 2016, 16:22 |
hmic |
you need to table to authenticate the user, so you cannot attach it to this table (in one go) - ever. |
# |
Oct 6th 2016, 16:22 |
hmic |
easy answer: before the logged in user is not known, you cannot attach footprint to the talbe |
# |
Oct 6th 2016, 16:20 |
nemmons |
@hmic oh, i see. I guess i don't understand the code base well enough yet to see how beforeFilter is relevant to my question. I'll keep reading. |
# |
Oct 6th 2016, 16:18 |
hmic |
still: even though this is a mess, it has for sure not been changed since 3.0, so not since may - 2015! |
# |
Oct 6th 2016, 16:18 |
hmic |
which are run on completely different times |
# |
Oct 6th 2016, 16:17 |
hmic |
nemmons: i am talking about the beforeFilter callback and event |