예제 #1
0
 public function saveAvatar($avatar)
 {
     if ($this->avatarImage) {
         $this->avatarImage->delete();
     }
     $attachment = new Attachment();
     $attachment->uploadFromFile($avatar);
     $attachment->save();
     $attachmentIndex = new AttachmentIndex();
     $attachmentIndex->attachment_id = $attachment->primaryKey;
     $attachmentIndex->entity = get_class($this);
     $attachmentIndex->entity_id = $this->primaryKey;
     $attachmentIndex->attribute = "avatarImage";
     $attachmentIndex->save();
 }
 public function saveIndex($id)
 {
     $relation = new AttachmentIndex();
     $relation->entity = $this->getEntityClass();
     $relation->entity_id = $this->getEntityId();
     $relation->attribute = $this->attribute;
     $relation->attachment_id = $id;
     $relation->save();
 }
예제 #3
0
 public function saveLogo($path)
 {
     $attachment = new Attachment();
     $attachment->uploadFromFile($path);
     $attachment->save();
     $attachmentIndex = new AttachmentIndex();
     $attachmentIndex->attachment_id = $attachment->primaryKey;
     $attachmentIndex->entity = get_class($this);
     $attachmentIndex->entity_id = 0;
     $attachmentIndex->attribute = "appLogoImage";
     $attachmentIndex->save();
     return $attachment;
 }