Use generic file model Plugin and App?

Hello everyone

In cakephp 3.
I have: Test/src/Model/Table/UsersTable.php

The next step I did:
bin/cake bake plugin User
bin/cake bake all users -p User

I see a file: Test/plugins/User/src/Model/Table/UsersTable.php

I want to use a generic file model: Test/src/Model/Table/UsersTable.php
Not used file UsersTable.php in Plugin User

It’s like public $uses = array (‘User’); In cakephp 2

I have a look $users = TableRegistry::get(‘Users’);
But I can not use $this->User->find.
Error: Table “User\Model\Table\UsersTable” is not associated with “Groups”

That must use $users->find
And have to declare $users = TableRegistry::get(‘Users’); On each function, that’s awkward
I do not know how to solve this problem
Can you tell me how to handle it ?

Thanks !

$users = TableRegistry::get('Users', ['className' => 'App\Model\Table\UsersTable']);

1 Like