for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
* @namespace
namespace Application\Options;
use Bluz\Validator\Traits\Validator;
use Bluz\Validator\Validator as v;
* Options Row
*
* @property string $namespace
* @property string $key
* @property string $value
* @property string $description
* @property string $created
* @property string $updated
* @category Application
* @package Options
class Row extends \Bluz\Db\Row
{
use Validator;
* {@inheritdoc}
protected function afterRead()
$this->value = unserialize($this->value);
}
protected function beforeSave()
$this->value = serialize($this->value);
$this->addValidator(
'namespace',
v::required()->slug()
);
'key',
protected function beforeInsert()
// unique validator
v::callback(function () {
return !$this->getTable()->findRowWhere(['key' => $this->key, 'namespace' => $this->namespace]);
})->setError('Key name "{{input}}" already exists')
protected function beforeUpdate()
$this->updated = gmdate('Y-m-d H:i:s');