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