Blame view

app/library/App/Model/Users.php 2.23 KB
0b7fb0e5   Alex Savenko   test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
  <?php
  
  use Phalcon\Validation;
  use Phalcon\Mvc\Model\Validator\Email as EmailValidator;
  
  class Users extends \Phalcon\Mvc\Model
  {
  
      /**
       *
       * @var integer
       * @Primary
       * @Identity
       * @Column(type="integer", length=32, nullable=false)
       */
      public $id;
  
      /**
       *
       * @var string
       * @Column(type="string", length=255, nullable=true)
       */
      public $name;
  
      /**
       *
       * @var string
       * @Column(type="string", length=255, nullable=true)
       */
      public $pass;
  
      /**
       *
       * @var string
       * @Column(type="string", length=255, nullable=true)
       */
      public $email;
  
      /**
       *
       * @var string
       * @Column(type="string", length=255, nullable=true)
       */
      public $role;
  
      /**
       *
       * @var string
       * @Column(type="string", nullable=true)
       */
      public $created_at;
  
      /**
       *
       * @var string
       * @Column(type="string", nullable=true)
       */
      public $updated_at;
  
      /**
       * Validations and business logic
       *
       * @return boolean
       */
      public function validation()
      {
          $validator = new Validation();
  
          $validator->add(
              'email',
              new EmailValidator(
                  [
                      'model'   => $this,
                      'message' => 'Please enter a correct email address',
                  ]
              )
          );
  
          return $this->validate($validator);
      }
  
      /**
       * Initialize method for model.
       */
      public function initialize()
      {
          $this->setSchema("public");
      }
  
      /**
       * Returns table name mapped in the model.
       *
       * @return string
       */
      public function getSource()
      {
          return 'users';
      }
  
      /**
       * Allows to query a set of records that match the specified conditions
       *
       * @param mixed $parameters
       * @return Users[]|Users
       */
      public static function find($parameters = null)
      {
          return parent::find($parameters);
      }
  
      /**
       * Allows to query the first record that match the specified conditions
       *
       * @param mixed $parameters
       * @return Users
       */
      public static function findFirst($parameters = null)
      {
          return parent::findFirst($parameters);
      }
  
  }