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\Roles;
use Bluz\Validator\Traits\Validator;
use Bluz\Validator\Validator as v;
* User Role
*
* @package Application\Roles
* @property integer $id
* @property string $name
class Row extends \Bluz\Db\Row
{
use Validator;
* Before Insert/Update
* @return void
protected function beforeInsert()
$this->addValidator(
'name',
v::required()->latin(),
v::callback(
function ($name) {
return !Table::getInstance()->findRowWhere(['name' => $name]);
}
)->setError('Role name "{{input}}" already exists')
);
* Before Update
protected function beforeUpdate()
return !in_array(strtolower($name), Table::getInstance()->getBasicRoles());
)->setError('Role "{{input}}" is basic and can\'t be editable'),
return $this->clean['name'] != $name;
)->setError('Role name "{{input}}" the same as original'),
* isBasic
* @return boolean
public function isBasic()
return in_array(strtolower($this->name), Table::getInstance()->getBasicRoles());