public function actionAdd_damage(){
$postDamage = new Damage_list();
if($postDamage->load(Yii::$app->request->post()) && $postDamage->validate()){
$imageDamage = UploadedFile::getInstances($postDamage, 'photo');
$postDamage->photo = 'uploads/'.md5($imageDamage->baseName).'.'.$imageDamage->extension;
if($postDamage->save()){
foreach($imageDamage as $file){
$file->saveAs($postDamage->photo);
}
Yii::$app->getSession()->setFlash('message', 'Post published successfull');
return $this->redirect(['site/table']);
}
else{
Yii::$app->getSession()->setFlash('message', 'Failed to post');
}
}
return $this->render('add_damage', ['postDamage' => $postDamage]);
}