Newer
Older
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
<?php
/**
* Copyright Maarch since 2008 under license.
* See LICENSE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief ExternalSignatoryBook Model
* @author dev@maarch.org
*/
namespace ExternalSignatoryBook\models;
use SrcCore\models\DatabaseModel;
use SrcCore\models\ValidatorModel;
class ExternalSignatoryBookModel
{
public static function get(array $aArgs = [])
{
ValidatorModel::arrayType($aArgs, ['select', 'where', 'data', 'orderBy']);
ValidatorModel::intType($aArgs, ['limit']);
$externalData = DatabaseModel::select([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
'table' => ['external_signatory_book'],
'where' => empty($aArgs['where']) ? [] : $aArgs['where'],
'data' => empty($aArgs['data']) ? [] : $aArgs['data'],
'orderBy' => empty($aArgs['orderBy']) ? [] : $aArgs['orderBy'],
'limit' => empty($aArgs['limit']) ? 0 : $aArgs['limit']
]);
return $externalData;
}
public static function getById(array $aArgs)
{
ValidatorModel::notEmpty($aArgs, ['id']);
ValidatorModel::intVal($aArgs, ['id']);
ValidatorModel::arrayType($aArgs, ['select']);
$externalData = ExternalSignatoryBookModel::get([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
'where' => ['id = ?'],
'data' => [$aArgs['id']]
]);
if (!empty($externalData)) {
return $externalData[0];
}
return [];
}
public static function create(array $aArgs)
{
ValidatorModel::notEmpty($aArgs, ['label', 'type', 'connection_data', 'otp_code']);
ValidatorModel::stringType($aArgs, ['label', 'type']);
$nextSequenceId = DatabaseModel::getNextSequenceValue(['sequenceId' => 'external_signatory_book_id_seq']);
DatabaseModel::insert([
'table' => 'external_signatory_book',
'columnsValues' => [
'id' => $nextSequenceId,
'label' => $aArgs['label'],
'type' => $aArgs['type'],
'connection_data' => $aArgs['connection_data'],
'otp_code' => $aArgs['otp_code'],
'message_content' => $aArgs['message_content'],
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
]
]);
return $nextSequenceId;
}
public static function update(array $args)
{
ValidatorModel::notEmpty($args, ['set', 'where', 'data']);
ValidatorModel::arrayType($args, ['set', 'where', 'data']);
DatabaseModel::update([
'table' => 'external_signatory_book',
'set' => $args['set'],
'where' => $args['where'],
'data' => $args['data']
]);
return true;
}
public static function delete(array $args)
{
ValidatorModel::notEmpty($args, ['where', 'data']);
ValidatorModel::arrayType($args, ['where', 'data']);
DatabaseModel::delete([
'table' => 'external_signatory_book',
'where' => $args['where'],
'data' => $args['data']
]);
return true;
}
}