36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace frontend\controllers;
|
|
|
|
use common\models\Getbin;
|
|
use Yii;
|
|
use yii\base\Exception;
|
|
|
|
class GetbinController extends \yii\web\Controller
|
|
{
|
|
public function actionIndex()
|
|
{
|
|
$model = new Getbin();
|
|
|
|
if($model->load(Yii::$app->request->post()) && $model->save()) {
|
|
try {
|
|
$model->map = $model->uploadGetbin($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
|
|
]);
|
|
}
|
|
|
|
}
|