I realized that when a model's find method is executed the _init method is executed first as a construct.
I have a model called Machine and another one called Shift. In the Shift model there is the machine_id property, and in the Machine model there is the subsidiary_id property, when I execute Shifit :: find I would like to take only the results where subsidiary_id that is in Machine is equal to the value passed.
This work only if a user related method where I call Shifit model:
Shift::query()
->related('machine')
->get();
If I call Shift Model without related an error occurs because machine.subsidiary_id does not exists. I'd like that related(machine) would be considered when I call Shift::query()
->get(); in _init method without having to explicitly use Related(machine)