for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @copyright Copyright (c) Flipbox Digital Limited
* @license https://github.com/flipbox/spark/blob/master/LICENSE
* @link https://github.com/flipbox/spark
*/
namespace flipbox\spark\models\traits;
use Craft;
use flipbox\spark\helpers\ModelHelper;
* @author Flipbox Factory <[email protected]>
* @since 1.2.0
trait ModelWithState
{
* @var boolean Enabled
public $enabled;
* @inheritdoc
public function isEnabled()
return (bool)$this->enabled;
}
public function isDisabled()
return !$this->isEnabled();
public function toEnabled()
$this->enabled = true;
return $this;
public function toDisabled()
$this->enabled = false;
public function stateRules()
return [
[
'enabled'
],
'safe',
'on' => [
ModelHelper::SCENARIO_DEFAULT
]
];
public function stateAttributeLabel()
'state' => Craft::t('app', 'State')