CakePHP 3 good practice -


i'm doing logic code in entities , don't know if it's practice. got object belongs place. placestable works treebehavior , want know place of object city place:

i'm doing , want know if it's practice:

class object extends entity {    protected $_accessible = [        '*'    => true,        'city' => true    ];     public function _getcity()    {       $places = tableregistry::get('zones');       $cityid = $places->getroot($this->place);       return $places->get($cityid);    } } 

then virtual field city cityentity


Comments