Premier commit
This commit is contained in:
44
overrides/user/models/User.php
Normal file
44
overrides/user/models/User.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user