<?php

namespace app\admin\controller\wechat;

use app\common\controller\Backend;
use app\admin\model\WechatResponse;

/**
 * 扣款服务签约列表
 *
 * @icon fa fa-circle-o
 */
class PlanRecord extends Backend
{

    protected $model = null;
//    protected $noNeedRight = ['check_text_unique'];

    public function _initialize()
    {
        parent::_initialize();
        $this->model = model('WechatPlanRecord');
    }

    /**
     * 编辑
     */
    public function edit($ids = null)
    {
        $row = $this->model->get(['id' => $ids]);
        if (!$row) {
            $this->error(__('No Results were found'));
        }
        if ($this->request->isPost()) {
            $params = $this->request->post("row/a");
            if ($params) {
                $row->save($params);
                $this->success();
            }
            $this->error();
        }
        $this->view->assign("row", $row);
        return $this->view->fetch();
    }
//
//    /**
//     * 判断价格是否唯一
//     * @internal
//     */
//    public function check_text_unique()
//    {
//        $row = $this->request->post("row/a");
//        $except = $this->request->post("except");
//        $text = isset($row['price']) ? $row['price'] : '';
//        if ($this->model->where('price', $text)->where(function ($query) use ($except) {
//                if ($except) {
//                    $query->where('price', '<>', $except);
//                }
//            })->count() == 0) {
//            $this->success();
//        } else {
//            $this->error(__('Text already exists'));
//        }
//    }

}
