phalcon - PhalconPHP - set the default foreign key action -
is there way define default foreign key action used in every model don't have keep defining inside every model below?
$this->hasone('id', '\namespace', 'id', [ 'foreignkey' => [ 'action' => \phalcon\mvc\model\relation::action_cascade ] ]);
override hasone().
class yourbasemodel extends \phalcon\mvc\model { protected function hasone($local, $remote_model, $remote_field, $options = null) { $options['foreignkey'] = [ 'action' => \phalcon\mvc\model\relation::action_cascade ]; parent::hasone($local, $remote_model, $remote_field, $options); } } class yourmodel extends yourbasemodel { public function initialize() { $this->hasone('id', '\namespace', 'id'); } }
Comments
Post a Comment