OrganizerForm.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace app\models;
  3. use yii\base\Model;
  4. class OrganizerForm extends Model
  5. {
  6. public $id;
  7. public $user_id;
  8. public $fio;
  9. public $at_org;
  10. public $org_type;
  11. public $phone;
  12. public $fax;
  13. public $firma_full;
  14. public $inn;
  15. public $zkpo;
  16. public $u_address;
  17. public $f_address;
  18. public $member;
  19. public $member_phone;
  20. public $member_email;
  21. public $site;
  22. public $files;
  23. public function rules()
  24. {
  25. return [
  26. [['user_id', 'fio', 'at_org', 'org_type'], 'required'],
  27. [['user_id', 'org_type', 'inn', 'zkpo', 'files'], 'integer', 'min' => 6, 'max' => 25],
  28. [['fio', 'at_org', 'phone', 'fax', 'firma_full', 'u_address', 'f_address', 'member', 'member_phone', 'member_email', 'site'], 'string', 'max' => 255],
  29. [['fio', 'at_org', 'phone', 'fax', 'firma_full', 'u_address', 'f_address', 'member', 'member_phone', 'member_email'], 'safe'],
  30. ['fax', 'match', 'pattern' => '/\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/'],
  31. ];
  32. }
  33. public function init(){
  34. $profile = new Profile;
  35. }
  36. public function register(){
  37. if (!$this->validate()) {
  38. return false;
  39. }
  40. $this->clients->setAttributes(
  41. [
  42. 'id' => $this->id,
  43. 'user_id' => $this->user_id,
  44. 'fio' => $this->fio,
  45. 'at_org' => $this->at_org,
  46. 'org_type' => $this->org_type,
  47. 'phone' => $this->phone,
  48. 'fax' => $this->fax,
  49. 'firma_full' => $this->firma_full,
  50. 'inn' => $this->inn,
  51. 'zkpo' => $this->zkpo,
  52. 'u_address' => $this->u_address,
  53. 'f_address' => $this->f_address,
  54. 'member' => $this->member,
  55. 'member_phone' => $this->member_phone,
  56. 'member_email' => $this->member_email,
  57. 'site' => $this->site,
  58. 'files' => $this->files,
  59. ]
  60. );
  61. return $this->profile->save();
  62. }
  63. }