JCommunityController.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Created by north.Deng's MAC
  4. * User: north.Deng
  5. * Date: 2018/2/28
  6. * Time: 下午12:30
  7. * description :
  8. */
  9. class JCommunityController extends AdminController
  10. {
  11. protected $fileds = [
  12. 'user_id' => '用户ID',
  13. 'name' => '用户名',
  14. 'mobile' => '手机',
  15. 'phone' => '电话',
  16. 'email' => '邮箱',
  17. 'birth' => '生日',
  18. 'sex' => '性别',
  19. 'address' => '地址',
  20. 'address_number' => '邮编',
  21. 'street' => '街道',
  22. 'card_number' => '身份证号',
  23. 'desc' => '备注',
  24. ];
  25. public function actionAdd()
  26. {
  27. $data = [];
  28. foreach ($this->fileds as $filed => $v) {
  29. $data[$filed] = Yii::app()->request->getParam($filed,'');
  30. if (empty($data[$filed])) {
  31. CommonFn::requestAjax(false, '请填写完整数据', array($filed));
  32. }
  33. }
  34. $community = new Community();
  35. $community->user_id = $data['user_id'];
  36. $community->user_info = [
  37. 'name' => $data['name'],
  38. 'mobile' => $data['mobile'],
  39. 'phone' => $data['phone'],
  40. 'email' => $data['email'],
  41. 'birth' => strtotime($data['birth']),
  42. 'sex' => (int)$data['sex'],
  43. ];
  44. $community->register_time = time();
  45. $community->address_number = $data['address_number'];
  46. $community->address = $data['address'];
  47. $community->street = $data['street'];
  48. $community->card_number = $data['card_number'];
  49. $community->desc = $data['desc'];
  50. $community->address = $data['address'];
  51. $community->save();
  52. CommonFn::requestAjax(true,'创建成功');exit;
  53. }
  54. }