1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
namespace App\Model\Table; |
4
|
|
|
|
5
|
|
|
use Cake\ORM\Query; |
|
|
|
|
6
|
|
|
use Cake\ORM\RulesChecker; |
|
|
|
|
7
|
|
|
use Cake\ORM\Table; |
8
|
|
|
use Cake\Validation\Validator; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Tickets Model |
12
|
|
|
* |
13
|
|
|
* @property \Cake\ORM\Association\HasMany $Operations |
14
|
|
|
* |
15
|
|
|
* @method \App\Model\Entity\Ticket get($primaryKey, $options = []) |
16
|
|
|
* @method \App\Model\Entity\Ticket newEntity($data = null, array $options = []) |
17
|
|
|
* @method \App\Model\Entity\Ticket[] newEntities(array $data, array $options = []) |
18
|
|
|
* @method \App\Model\Entity\Ticket|bool save(\Cake\Datasource\EntityInterface $entity, $options = []) |
19
|
|
|
* @method \App\Model\Entity\Ticket patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) |
20
|
|
|
* @method \App\Model\Entity\Ticket[] patchEntities($entities, array $data, array $options = []) |
21
|
|
|
* @method \App\Model\Entity\Ticket findOrCreate($search, callable $callback = null, $options = []) |
22
|
|
|
* |
23
|
|
|
* @mixin \Cake\ORM\Behavior\TimestampBehavior |
24
|
|
|
*/ |
|
|
|
|
25
|
|
|
class TicketsTable extends Table { |
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Initialize method |
29
|
|
|
* |
30
|
|
|
* @param array $config The configuration for the Table. |
|
|
|
|
31
|
|
|
* @return void |
|
|
|
|
32
|
|
|
*/ |
33
|
7 |
|
public function initialize(array $config): void { |
|
|
|
|
34
|
7 |
|
parent::initialize($config); |
35
|
|
|
|
36
|
7 |
|
$this->setTable('tickets'); |
37
|
7 |
|
$this->setDisplayField('title'); |
38
|
7 |
|
$this->setPrimaryKey('id'); |
39
|
|
|
|
40
|
7 |
|
$this->addBehavior('Timestamp'); |
41
|
|
|
|
42
|
7 |
|
$this->hasMany('Operations', [ |
43
|
7 |
|
'foreignKey' => 'ticket_id' |
|
|
|
|
44
|
|
|
]); |
45
|
7 |
|
$this->belongsTo('Tickettypes', [ |
46
|
7 |
|
'foreignKey' => 'tickettype_id' |
|
|
|
|
47
|
|
|
]); |
48
|
7 |
|
$this->belongsTo('Ticketstatuses', [ |
49
|
7 |
|
'foreignKey' => 'ticketstatus_id' |
|
|
|
|
50
|
|
|
]); |
51
|
7 |
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Default validation rules. |
55
|
|
|
* |
56
|
|
|
* @param \Cake\Validation\Validator $validator Validator instance. |
|
|
|
|
57
|
|
|
* @return \Cake\Validation\Validator |
|
|
|
|
58
|
|
|
*/ |
59
|
3 |
|
public function validationDefault(Validator $validator): Validator { |
|
|
|
|
60
|
|
|
//$validator |
|
|
|
|
61
|
|
|
// ->integer('id') |
|
|
|
|
62
|
|
|
// ->allowEmptyFor('id', 'create'); |
|
|
|
|
63
|
|
|
|
64
|
|
|
$validator |
65
|
3 |
|
->requirePresence('title', 'create') |
|
|
|
|
66
|
3 |
|
->notEmptyString('title'); |
|
|
|
|
67
|
|
|
|
68
|
|
|
$validator |
69
|
3 |
|
->allowEmptyString('title', 'create'); |
|
|
|
|
70
|
|
|
|
71
|
3 |
|
return $validator; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
} |
75
|
|
|
|