kokjan/frontend/controllers/ElectricController.php

39 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2026-02-25 06:59:34 +00:00
<?php
namespace frontend\controllers;
use common\models\Electric;
use Yii;
use yii\base\Exception;
class ElectricController extends \yii\web\Controller
{
public function actionIndex()
{
$model = new Electric();
if($model->load(Yii::$app->request->post()) && $model->save()) {
try {
$model->map = $model->uploadElectric($model, 'map');
Yii::$app->session->setFlash('success', 'บันทึกข้อมูลเรียบร้อยแล้ว กรุณารอการติดต่อกลับจากเจ้าหน้าที่');
Yii::$app->hanuman->sendNotify('มีการแจ้งแบบคำร้องขอซ่อมไฟฟ้า/ไฟสาธารณะ');
} catch (Exception $exception) {
Yii::$app->session->setFlash('error', $exception->getMessage());
}
return $this->redirect(['index']);
}else{
//var_dump($model->getFirstErrors());
}
return $this->render('index', [
'model' => $model
]);
}
}