| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- /**
- * Created by PhpStorm.
- * User: chenkuan
- * Date: 2017/12/26
- * Time: 下午1:49
- */
- namespace wechat\models\forms;
- use wechat\models\IndexApi;
- use yii\base\Model;
- class PartnerApplyForm extends Model
- {
- public $name;
- public $mobile;
- public $email;
- public $memo;
- public $type;
- /**
- * @return array
- */
- public function rules()
- {
- return [
- [['type'], 'integer'],
- [['create_time'], 'safe'],
- [['name', 'email'], 'string', 'max' => 255],
- [['mobile'], 'string', 'max' => 30],
- [['memo'], 'string', 'max' => 1000],
- ];
- }
- public function savePartnerApply()
- {
- if ($this->validate()) {
- $api = new IndexApi();
- $data = [];
- $data['type'] = $this->type;
- $data['name'] = $this->name;
- $data['mobile'] = $this->mobile;
- $data['email'] = $this->email;
- $data['memo'] = $this->memo;
- $result = $api->savePartnerApply($data);
- if ($result['code'] == 1) {
- return true;
- } else {
- if (is_array($result['message'])) {
- $this->addErrors($result['message']);
- } else {
- $this->addError('name', $result['message']);
- }
- }
- }
- return !$this->hasErrors();
- }
- }
|