45 lines
920 B
PHP
45 lines
920 B
PHP
<?php
|
|
namespace app\overrides\user\models;
|
|
|
|
use Piko\DbRecord;
|
|
|
|
class User extends \app\modules\user\models\User
|
|
{
|
|
/**
|
|
* {@inheritDoc}
|
|
* @see \Piko\DbRecord::beforeSave()
|
|
*/
|
|
protected function beforeSave($isNew): bool
|
|
{
|
|
if (is_array($this->profil)) {
|
|
$this->profil = json_encode($this->profil);
|
|
}
|
|
|
|
return parent::beforeSave($isNew);
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
* @see \Piko\DbRecord::afterSave()
|
|
*/
|
|
protected function afterSave(): void
|
|
{
|
|
$this->profil = empty($this->profil) ? [] : json_decode($this->profil, true);
|
|
|
|
parent::afterSave();
|
|
}
|
|
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
* @see \Piko\DbRecord::load()
|
|
*/
|
|
public function load($id = 0): DbRecord
|
|
{
|
|
parent::load($id);
|
|
$this->profil = empty($this->profil) ? [] : json_decode($this->profil, true);
|
|
|
|
return $this;
|
|
}
|
|
}
|