-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserAdd.php
More file actions
46 lines (38 loc) · 1.07 KB
/
UserAdd.php
File metadata and controls
46 lines (38 loc) · 1.07 KB
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
<?php
declare(strict_types=1);
/*
* This file is part of the QuidPHP package <https://quidphp.com>
* Author: Pierre-Philippe Emond <emondpph@gmail.com>
* License: https://github.com/quidphp/core/blob/master/LICENSE
*/
namespace Quid\Core\Col;
// userAdd
// class for a column which stores the current user id on insert
class UserAdd extends EnumAlias
{
// config
protected static array $config = [
'required'=>false,
'general'=>true,
'visible'=>['validate'=>'notEmpty'],
'relation'=>'user',
'duplicate'=>false,
'editable'=>false,
'complex'=>'div',
'check'=>['kind'=>'int']
];
// onInsert
// donne le user courant lors d'un insert
// il faut vérifier que boot hasSession car la row session à un champ userAdd
final protected function onInsert($value,array $row,array $option)
{
$return = 1;
$boot = static::bootReady();
if(!empty($boot) && $boot->hasSession())
$return = $boot->session()->user();
return $return;
}
}
// init
UserAdd::__init();
?>