File: /home/aliazzsr/api.crm.vqode.com/components/behaviors/EulaBehavior.php
<?php
namespace app\components\behaviors;
use app\models\core\Setting;
use app\models\core\User;
use yii\base\Behavior;
use yii\db\ActiveRecord;
class EulaBehavior extends Behavior
{
/** @var array */
public $when;
public function events()
{
return [
ActiveRecord::EVENT_AFTER_UPDATE => 'afterUpdate',
];
}
public function afterUpdate($event)
{
/** @var Setting $model */
$model = $event->sender;
foreach ($this->when as $attribute => $value) {
if ($model->{$attribute} != $value) {
return true;
}
}
User::resetEulaAcceptance();
return true;
}
}