Hello,
I want to expose a virtual field “deletable” which is set to true when several conditions match.
One of this condition needs to query the position of the current entity.
Here is how I am trying to do this:
namespace App\Model\Entity;
use Cake\ORM\Entity;
use Cake\ORM\TableRegistry;
use Cake\Log\Log;class Notice extends Entity
{
protected function _getDeletable() { $notices = TableRegistry::get('Notices'); $query = $notices->find() ->where(['lease_id' => $this->_properties['lease_id']]) ->order([ 'name' => 'DESC', 'receipt_date2' => 'DESC' ]); $result = $query->first(); } return $result; } protected $_virtual = ['deletable'];
}
I got an error: 256 recursive limit. I believe this is due to the fact that the deletable virtual field is also exposed during my query …
I tried to use ->hiddenProperties([‘deletable’]) without success.
How can I hide the virtual property only while calculation?