php use Phalcon Mvc Model Validator Uniqueness class Users extends Pha

 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
<?php
use Phalcon\Mvc\Model\Validator\Uniqueness;
class Users extends \Phalcon\Mvc\Model {
public function initialize() {
$this->hasMany('id', '\Redozote\Models\Diaries', 'user_id', array(
'alias' => 'diaries'
));
$this->hasMany('id', '\Redozote\Models\Friends', 'user_id', array(
'alias' => 'friends'
));
$this->hasMany('id', '\Redozote\Models\CommunityUsers', 'user_id', array(
'alias' => 'comm'
));
$this->hasMany('id', 'Feeds', 'user', array(
'alias' => 'feeds'
));
}
public function validation() {
$this->validate(new Uniqueness(array(
'field' => 'email',
'message' => 'Указанный E-mail занят',
)));
$this->validate(new Uniqueness(array(
'field' => 'login',
'message' => 'Указанный никнейм занят',
)));
return $this->validationHasFailed() != true;
}
}