|
1
|
|
|
<?php |
|
2
|
|
|
namespace App\Model\Table; |
|
3
|
|
|
|
|
4
|
|
|
use Cake\ORM\Query; |
|
5
|
|
|
use Cake\ORM\RulesChecker; |
|
6
|
|
|
use Cake\ORM\Table; |
|
7
|
|
|
use Cake\Validation\Validator; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Operations Model |
|
11
|
|
|
* |
|
12
|
|
|
* @property \Cake\ORM\Association\BelongsTo $Tickets |
|
13
|
|
|
* |
|
14
|
|
|
* @method \App\Model\Entity\Operation get($primaryKey, $options = []) |
|
15
|
|
|
* @method \App\Model\Entity\Operation newEntity($data = null, array $options = []) |
|
16
|
|
|
* @method \App\Model\Entity\Operation[] newEntities(array $data, array $options = []) |
|
17
|
|
|
* @method \App\Model\Entity\Operation|bool save(\Cake\Datasource\EntityInterface $entity, $options = []) |
|
18
|
|
|
* @method \App\Model\Entity\Operation patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) |
|
19
|
|
|
* @method \App\Model\Entity\Operation[] patchEntities($entities, array $data, array $options = []) |
|
20
|
|
|
* @method \App\Model\Entity\Operation findOrCreate($search, callable $callback = null, $options = []) |
|
21
|
|
|
* |
|
22
|
|
|
* @mixin \Cake\ORM\Behavior\TimestampBehavior |
|
23
|
|
|
*/ |
|
24
|
|
|
class OperationsTable extends Table |
|
25
|
|
|
{ |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Initialize method |
|
29
|
|
|
* |
|
30
|
|
|
* @param array $config The configuration for the Table. |
|
31
|
|
|
* @return void |
|
32
|
|
|
*/ |
|
33
|
4 |
|
public function initialize(array $config) |
|
34
|
|
|
{ |
|
35
|
4 |
|
parent::initialize($config); |
|
36
|
|
|
|
|
37
|
4 |
|
$this->table('operations'); |
|
|
|
|
|
|
38
|
4 |
|
$this->displayField('id'); |
|
|
|
|
|
|
39
|
4 |
|
$this->primaryKey('id'); |
|
|
|
|
|
|
40
|
|
|
|
|
41
|
4 |
|
$this->addBehavior('Timestamp'); |
|
42
|
|
|
|
|
43
|
4 |
|
$this->belongsTo('Tickets', [ |
|
44
|
4 |
|
'foreignKey' => 'ticket_id', |
|
45
|
|
|
'joinType' => 'INNER' |
|
46
|
|
|
]); |
|
47
|
4 |
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Default validation rules. |
|
51
|
|
|
* |
|
52
|
|
|
* @param \Cake\Validation\Validator $validator Validator instance. |
|
53
|
|
|
* @return \Cake\Validation\Validator |
|
54
|
|
|
*/ |
|
55
|
2 |
|
public function validationDefault(Validator $validator) |
|
56
|
|
|
{ |
|
57
|
|
|
$validator |
|
|
|
|
|
|
58
|
2 |
|
->integer('id') |
|
59
|
2 |
|
->allowEmpty('id', 'create'); |
|
60
|
|
|
|
|
61
|
|
|
$validator |
|
|
|
|
|
|
62
|
2 |
|
->dateTime('start') |
|
63
|
2 |
|
->requirePresence('start', 'create') |
|
64
|
2 |
|
->notEmpty('start'); |
|
65
|
|
|
|
|
66
|
|
|
$validator |
|
|
|
|
|
|
67
|
2 |
|
->dateTime('end') |
|
68
|
2 |
|
->requirePresence('end', 'create') |
|
69
|
2 |
|
->notEmpty('end'); |
|
70
|
|
|
|
|
71
|
|
|
$validator |
|
|
|
|
|
|
72
|
2 |
|
->allowEmpty('description', 'create'); |
|
73
|
|
|
|
|
74
|
2 |
|
return $validator; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Returns a rules checker object that will be used for validating |
|
79
|
|
|
* application integrity. |
|
80
|
|
|
* |
|
81
|
|
|
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified. |
|
82
|
|
|
* @return \Cake\ORM\RulesChecker |
|
83
|
|
|
*/ |
|
84
|
1 |
|
public function buildRules(RulesChecker $rules) |
|
85
|
|
|
{ |
|
86
|
1 |
|
$rules->add($rules->existsIn(['ticket_id'], 'Tickets')); |
|
87
|
|
|
|
|
88
|
1 |
|
return $rules; |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.