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;
     }
 }
 /**
  * Displays a single ContactRequest model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $attaches = ContactAttachment::find()->where(['request_id' => $id])->all();
     return $this->render('view', ['model' => $model, 'attaches' => $attaches]);
 }