示例#1
0
 public function upload()
 {
     if ($this->validate()) {
         foreach ($this->attachments as $file) {
             $fname = $this->id . '-' . $file->baseName . '.' . $file->extension;
             $file->saveAs('uploads/' . $fname);
             $attachment = new ContactAttachment();
             $attachment->filename = $fname;
             $attachment->request_id = $this->id;
             $attachment->save();
         }
         return true;
     } else {
         return false;
     }
 }