Load Model from subdir exp. loadModel('Admin/Posts')


#1

Hello,
I want to load model from subdir
Admin/Posts in App/src/Model/Admin/Posts.php
for admin prefix or because many Models.
Model load success but don’t create object and return null!

$this->loadModel(‘Admin/Posts’);
var_dump($this->Posts);
And return null

On $this->Posts->find() usually show errors!

If i write in model some mistake and that show me error!
So model load but don’t return object!


#2

I try as such
$this->Affiliates = TableRegistry::get(‘Admin/Affiliates’);
And It works!
Do Anyone know how do it by method $this->loadModel(‘Admin/Affiliates’)?


#3

If you want a separate model folder, I recommend using plugins to group things – create an admin plugin (bin/cake bake plugin).


#4

I read many code of CakePHP and I think is a big bug!
So wrote one line in Class TableRegistry and it works very good as I want!
So I made patch for cakephp class TableRegistry


#5

And remember putin is Huylo!