123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- namespace backend\controllers;
- use backend\base\CommonController;
- use backend\base\Help;
- use common\models\HouseEmail;
- use Yii;
- /**
- * 给楼盘设置单独发送的邮箱
- * Class HouseemailController
- * @package backend\controllers
- */
- class HouseemailController extends CommonController
- {
- /**
- * @return string
- */
- public function actionIndex()
- {
- return $this->render($this->action->id);
- }
- /**
- * 查询数据
- * @return mixed
- */
- public function actionIndexform()
- {
- $Post = Yii::$app->request->post();
- $Model = new HouseEmail();
- $List = $Model->getList($Post);
- if ($List) {
- foreach ($List as &$val) {
- $val['create_at'] = date('Y-m-d H:i', $val['create_at']);
- }
- return Help::JsonData(0, Yii::t('app', 'get_success'), $Model->Total($Post), $List);
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'get_error'));
- }
- /**
- * @return string
- */
- public function actionAdd()
- {
- return $this->render($this->action->id);
- }
- /**
- * 添加数据
- * @return mixed
- */
- public function actionAddform()
- {
- $Model = new HouseEmail();
- $Model->scenario = 'add';
- if ($Model->load(Yii::$app->request->post(), '') && $Model->save()) {
- return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_success'));
- }
- return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_error'), $Model->errors);
- }
- /**
- * @return string
- */
- public function actionEdit()
- {
- $Row = HouseEmail::findOne(Yii::$app->request->get('id'));
- if ($Row) {
- return $this->render($this->action->id, ['row' => $Row]);
- }
- }
- /**
- * 修改数据
- * @return mixed
- * @throws \Throwable
- * @throws \yii\db\StaleObjectException
- */
- public function actionEditform()
- {
- $Row = HouseEmail::findOne(Yii::$app->request->post('id'));
- $Row->scenario = 'edit';
- if ($Row->load(Yii::$app->request->post(), '') && $Row->save()) {
- return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'), $Row->errors);
- }
- /**
- * 删除数据
- * @return mixed
- * @throws \Throwable
- * @throws \yii\db\StaleObjectException
- */
- public function actionDelemail()
- {
- $Row = HouseEmail::findOne(Yii::$app->request->post('id'));
- if ($Row->delete()) {
- return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'del_success'));
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'del_error'), $Row->errors);
- }
- }
|