protected function beforeSave() { if (empty($this->type)) { $this->type = $this->__type; } if (empty($this->md5)) { if (!empty($this->{'s3.ETag'})) { $this->md5 = str_replace('"', '', $this->{'s3.ETag'}); } elseif (!empty($this->filename) && file_exists($this->filename)) { $this->md5 = md5_file($this->filename); } else { $this->md5 = md5($this->slug); } } return parent::beforeSave(); }