예제 #1
0
 /**
  * Updates the stored password to a new hash if required.
  *
  * @param string    $string
  * @param BaseModel $model
  * @param string    $column
  */
 private function updatedSavedHash($string, BaseModel $model, $column)
 {
     // Generate a new hash
     $newHash = $this->generateHash($string);
     $model->{$column} = $newHash;
     $model->save();
 }
예제 #2
0
 /**
  * Return the properties in an array.
  *
  * @return array
  */
 public function toArray()
 {
     $array = parent::toArray();
     $array['user'] = $this->user;
     ksort($array);
     return $array;
 }
예제 #3
0
 /**
  * Delete the old thumbnail image on save if changing it
  * @param array $options
  *
  * @return bool
  * @throws \Exception
  */
 public function save(array $options = [])
 {
     /**
      * Remember these IDs now because the parent::save method clears
      * the isDirty flag and the original data.
      */
     $originalThumbnailImageFileId = null;
     if ($this->isDirty('thumbnailImageFileId')) {
         $originalThumbnailImageFileId = $this->getOriginal('thumbnailImageFileId');
     }
     // Save the model
     $result = parent::save($options);
     if ($originalThumbnailImageFileId && ($originalThumbnailImageFile = ImageFile::find($originalThumbnailImageFileId))) {
         $originalThumbnailImageFile->delete();
     }
     return $result;
 }
예제 #4
0
 /**
  * When deleting an ImageFile also delete the actual file it represents in the file system.
  * The relation on the database will take care of setting references to this image file to null and
  * deleting image_file_text entries.
  *
  * @param bool $deleteFiles
  *
  * @throws \Exception
  * @return bool|null
  */
 public function delete($deleteFiles = true)
 {
     if ($deleteFiles) {
         $this->dispatch(new DeleteFileJob($this->getPath()));
     }
     // FIXME: What if jobs are currently processing/waiting?
     // TODO: Delete thumbnail here?
     // TODO: Delete annotation here?
     return parent::delete();
 }
예제 #5
0
파일: User.php 프로젝트: antriver/ctrlv-api
 /**
  * Return the properties in an array.
  *
  * @param bool $authenticated If this is the current logged in user we return more info.
  *
  * @return array
  */
 public function toArray($authenticated = false)
 {
     $array = parent::toArray();
     $array['url'] = $this->getUrl();
     // Is the current user?
     if (Auth::check() && Auth::user()->userId == $this->userId) {
         // Any extra info for the account owner
         $array['defaultPassword'] = !!$this->defaultPassword;
     } else {
         unset($array['email']);
         unset($array['defaultAnonymous']);
         unset($array['moderator']);
         unset($array['updatedAt']);
     }
     ksort($array);
     return $array;
 }
예제 #6
0
 /**
  * Upon deleting the Image also delete the ImageFiles.
  *
  * @return bool|null
  * @throws \Exception
  */
 public function delete()
 {
     $this->table = 'images';
     if ($imageFile = $this->getImageFile()) {
         $imageFile->delete();
     }
     if ($thumbnailImageFile = $this->getThumbnailImageFile()) {
         $thumbnailImageFile->delete();
     }
     if ($annotationImageFile = $this->getAnnotationImageFile()) {
         $annotationImageFile->delete();
     }
     if ($uncroppedImageFile = $this->getUncroppedImageFile()) {
         $uncroppedImageFile->delete();
     }
     $result = parent::delete();
     $this->table = 'view_images';
     return $result;
 }