protected function prepareSave() { if (!($profile = $this->getUserProfile())) { $this->assignUserProfile(); } parent::prepareSave(); }
public function validation() { if ($_SERVER['PHWOOLCON_PHALCON_VERSION'] > '2010000') { $validator = new Validation(); $validator->add('key', new StringLength(['min' => 3, 'max' => 32])); } else { $validator = new \Phalcon\Mvc\Model\Validator\StringLength(['field' => 'key', 'min' => 3, 'max' => 32]); } $this->validate($validator); return parent::validation(); }
public function __construct($config) { $this->config = $config; $ormOptions = $config['orm_options']; $ormOptions['distributed'] = $config['distributed']; Model::setup($ormOptions); if (fnGet($this->config, 'query_log')) { Events::attach('db:beforeQuery', function (Event $event) { /* @var Adapter $adapter */ $adapter = $event->getSource(); $binds = $adapter->getSqlVariables(); Log::debug($adapter->getSQLStatement() . '; binds = ' . var_export($binds, 1)); }); } }
public function initialize() { $class = OrderData::class; $this->hasOne('id', $class, 'order_id', ['alias' => 'order_data']); parent::initialize(); }
protected function prepareSave() { $this->getData('avatar') or $this->setData('avatar', $this->generateAvatarUrl()); $this->extra_data or $this->extra_data = []; parent::prepareSave(); }