Problem inheritance Table directory structure

Hi. I find it impossible to organize inheritance models in subdirectories under the Table directory. LoadModel does not work.
I followed this information, (https://stackoverflow.com/questions/47717720/organize-models-in-subdirectories-cakephp-3) but it does not work for me either.
Any ideas ?

Did you note the part where the solution said “The above isn’t working code. I’m just demonstrating what the function is you need to override.”? Show us what you’ve tried to address your particular scenario, and explain what part of it isn’t working (including specific error messages, etc.).

Hi, I have a base model called Posts. From this model the following are inherited:
Blocks, Pages, News and Faqs.
When I perform the loadModel, the property is not created with the className of the table into Controller. Example:
Controller:
public function initialize()
{
parent::initialize();

    $this->loadModel('Clinics');
    $this->loadModel('ClinicsData');
    $this->loadModel('Comments');
    $this->loadModel('Users');
    $this->loadModel('Searches');
    $this->loadModel('Post/Pages'); // this load should create $this->Pages, but not.
}

Content file PagesTable.php in /Table/Post dir

namespace App\Model\Table\Post;
use Cake\Event\Event;
use Cake\ORM\Query;
use Cake\Validation\Validator;
use App\Model\Table\PostsTable;

class PagesTable extends PostsTable {

public function initialize(array $config)
{

    parent::initialize($config);

}

}

The application has 130 Models, I would like to be able to hierarchize the models and ccontrollers to avoid chaos.

Thanks.35

The SO post you linked has a suggested partial solution, but indicates that you need to make changes for your particular situation. Have you tried to do that? Or just copy-pasted what was there and it didn’t work?

I tried to make modifications and tests adapting the example.
But it does not work. I think that the creators of CakePHP should take into account the hierarchical development of Models and controllers. Especially to be able to make big web applications. In Object Oriented programming, inheritance is a very important and very powerful characteristic. The majority of the developers realize architectures of flat designs, and this is valid for small developments, but not for the great ones.

Sorry for my english.

Without showing what you tried in terms of modifications, nobody can say whether you were close or not. And inheritance is supported 100%, just not in a hierarchical directory structure. I can understand the desire to lay things out like this, but I’ve long since gotten over the aesthetics of it and accepted the practicality of following the conventions.

Ok, thanks. :grinning: