Exemplo n.º 1
0
Arquivo: User.php Projeto: semnt/tp01
 public function setModelAttributes($attrs)
 {
     $model = $this->getModel();
     // password
     if (strlen($attrs['password'])) {
         $model->setPassword($attrs['password']);
     }
     unset($attrs['password']);
     // groups
     $model->setGroups($attrs['groups']);
     unset($attrs['groups']);
     // enabled
     $model->setEnabled($attrs['enabled']);
     unset($attrs['enabled']);
     parent::setModelAttributes($attrs);
 }
Exemplo n.º 2
0
Arquivo: Image.php Projeto: semnt/tp01
 public function save()
 {
     $model = parent::save();
     if (strlen($this->upload_key)) {
         if ($this->upload_key == '__clear__') {
             $model->deleteImage();
             $model->save();
         } else {
             $path = \app\helpers\Upload::getTmpUploadPath($this->upload_key);
             if (is_file($path)) {
                 $model->pullImage($path);
                 $model->save();
                 FileHelper::unlink($path);
             }
         }
     }
     return $model;
 }