Log message #4261848

# At Username Text
# Apr 23rd 2021, 17:24 kevin.pfeifer but you can basically set the first parameter (for me `ParentProjects` and `ChildProjects` ) as whatever you like
# Apr 23rd 2021, 17:24 blackjccl Thank you that was the mistake @kevin.pfeifer @admad
# Apr 23rd 2021, 17:24 kevin.pfeifer depending on your associations you need to set the right parameters described in https://book.cakephp.org/4/en/orm/associations.html
# Apr 23rd 2021, 17:23 slackebot projects i call `$project = $this->Projects->get( $id, [ 'contain' => ['Childcts'] ]);`
# Apr 23rd 2021, 17:23 slackebot 'joinTable' => 'projects_projects', 'foreignKey' => 'parent_id', 'targetForeignKey' => 'child_id' ] );``` Basically here i only have a `projects` table with an id and a separate `projects_projects` table with only the columns `parent_id` and `child_id` If i want to access the parent projects i call `$project = $this->Projects->get( $id, [ 'contain' => ['ParentProjects'] ]);` And i want to access the child
# Apr 23rd 2021, 17:23 kevin.pfeifer @tyler.adam.lazenby here is an example for a Parent-Child Join for Projects with custom Identifieres ``` $this->belongsToMany( 'ParentProjects', [ 'className' => 'Projects', 'joinTable' => 'projects_projects', 'foreignKey' => 'child_id', 'targetForeignKey' => 'parent_id' ] ); $this->belongsToMany( 'ChildProjects', [ 'className' => 'Projects',
# Apr 23rd 2021, 17:15 admad read the 1st section of this page and you will have your answer https://book.cakephp.org/4/en/orm/associations.html
# Apr 23rd 2021, 17:13 tyler.adam.lazenby or is the association name the first property of the declaration?
# Apr 23rd 2021, 17:12 tyler.adam.lazenby now I need to figure out how to give the associations unique names. I thought this would work but.... ```$this->belongsTo('Users', [ 'foreignKey' => 'user_id', 'joinType' => 'INNER', 'property' => 'account_holder' ]); $this->hasMany('Users', [ 'foreignKey' => 'account_id' ]);```
# Apr 23rd 2021, 17:08 tyler.adam.lazenby @admad oh right.... that... makes sense. I feel dumb
# Apr 23rd 2021, 17:08 kevin.pfeifer @blackjccl to be more specific: Your Classname is `ClickMeetingRestClient` but your filename is `ClickMeetingRestclient.php`
# Apr 23rd 2021, 17:07 admad @blackjccl geez man how much spoon feeding do you need? @kevin.pfeifer told you exactly what your mistake is
# Apr 23rd 2021, 17:06 kevin.pfeifer which is the identifier for that relation
# Apr 23rd 2021, 17:06 kevin.pfeifer ``` $this->belongsTo('Users', [ 'foreignKey' => 'user_id', 'joinType' => 'INNER', ]); $this->hasMany('Users', [ 'foreignKey' => 'account_id' ]);``` have both `Users` as a first parameter
# Apr 23rd 2021, 17:06 blackjccl @admad what do you mean i'm doing wrong
# Apr 23rd 2021, 17:04 admad @tyler.adam.lazenby Association names need to be unique
# Apr 23rd 2021, 17:04 kevin.pfeifer you file as a lower `c` for Client
# Apr 23rd 2021, 17:03 admad you have casing issue in your filename
# Apr 23rd 2021, 17:03 blackjccl @admad Yes
# Apr 23rd 2021, 17:01 admad @blackjccl and you have `class ClickMeetingRestClient {..}` in the file?
# Apr 23rd 2021, 16:59 slackebot 'joinType' => 'INNER', ]); $this->hasMany('Users', [ 'foreignKey' => 'account_id' ]); $this->hasMany('Addresses', [ 'foreignKey' => 'account_id', ]); }```
# Apr 23rd 2021, 16:59 tyler.adam.lazenby Here is my source ```/** * Initialize method * * @param array $config The configuration for the Table. * @return void */ public function initialize(array $config): void { parent::initialize($config); $this->setTable('accounts'); $this->setDisplayField('name'); $this->setPrimaryKey('id'); $this->addBehavior('Timestamp'); $this->belongsTo('Users', [ 'foreignKey' => 'user_id',
# Apr 23rd 2021, 16:59 blackjccl Hi I am using cakephp 4 and I have created a Custom class and added a folder with my class inside the src `src/ClickMeeting/ClickMeetingRestclient.php` and in my code it is like this `namespace App\ClickMeeting;` and in I am using it like this in my component `use App\ClickMeeting\ClickMeetingRestClient;` but when I run it on my server I get this error `Class 'App\ClickMeeting\ClickMeetingRestClient' not found`
# Apr 23rd 2021, 16:58 tyler.adam.lazenby so if I make it know that it has a relationship to the user via its user_id, it can get $account->user but if I add in the relationship for hasMany users, then it stops realizing that, even though both are configured
# Apr 23rd 2021, 16:58 tyler.adam.lazenby But only the first declaration is being used
# Apr 23rd 2021, 16:57 tyler.adam.lazenby I am trying to configure the Accounts table to know that it can relate to users and and to the single user. The users have an account ID and the accounts table has a user_id
# Apr 23rd 2021, 16:57 tyler.adam.lazenby well actually its exactly one
# Apr 23rd 2021, 16:57 tyler.adam.lazenby Basically accounts can have many users but there is at least one user who is considered the account holder
# Apr 23rd 2021, 16:56 tyler.adam.lazenby I have both a users table and an accounts table
# Apr 23rd 2021, 16:56 tyler.adam.lazenby OK I am now running into something different
# Apr 23rd 2021, 16:55 slackebot the controller methods be adjusted (maybe?) because they authorization is “injected” via a middleware • And then also with the same plugin and the same Request Policy but a more controller adjustable approach where you can call that Request Policy Class again with `$this->Authorization->can($this->request, 'access')` and no “injected” middleware
# Apr 23rd 2021, 16:55 slackebot index). These also need to be checked in the used controller method via `->authorize($entity)` for entity related authorization or `$this->Authorization->applyScope($this->Users->find())` for table/query related authorization • Then we have https://github.com/CakeDC/auth which lets you handle everything but with a more generic Request policy (so not 1 Class per entity/table but 1 Class for *everything*) which doesn’t need to have
# Apr 23rd 2021, 16:55 kevin.pfeifer Please correct me if I am wrong but now it seems like there are now 3 main ways how you can handle configuration for authorization: • The “default” cakephp/authorization way where you have Policy Classes for each Entity like `UserPolicy::canEdit()` (for all the entity related authorization like add, edit, view and delete) and Tables `UsersTablePolicy::scopeIndex()` (for mostly query related authorization like
# Apr 23rd 2021, 16:00 tyler.adam.lazenby Yeah I know. I fully plan on implimenting it in the near future, and I understand the need to not paint myself further into a corner. BUT this is something I need now and for a single action... and it wouldn't exactly be business smart at this point to change that much source code when I have a deadline for a simple change.
# Apr 23rd 2021, 15:59 admad > I want to authorize based on actions Ditto
# Apr 23rd 2021, 15:57 admad cakedc/auth's RBAC policy allows handling all permission from a single config file. So you would we removing good from 50+ controllers
# Apr 23rd 2021, 15:56 tyler.adam.lazenby some with over 15 methods.
# Apr 23rd 2021, 15:56 tyler.adam.lazenby right, but we are talking about altering the logic for about 50 controllers at this point
# Apr 23rd 2021, 15:53 ndm No, it's for the plugin, which has a component too. The policy would be a table policy, so for example `UsersTablePolicy` (wrong name in my previous comment, sorry). Again, not a fan, I'd rather use a request policy if I want to authorize based on actions :)
# Apr 23rd 2021, 15:51 tyler.adam.lazenby not the authorization plugin?
# Apr 23rd 2021, 15:51 tyler.adam.lazenby also isn't this for the auth component