1 | <?php |
||
9 | |||
10 | /** |
||
11 | * |
||
12 | * @property string $_id |
||
13 | * @property string $title |
||
14 | * @property integer $status |
||
15 | * @property BarSchema $bar |
||
16 | * |
||
17 | */ |
||
18 | |||
19 | |||
20 | class FooSchema extends Schema |
||
21 | { |
||
22 | public function schema() |
||
23 | { |
||
24 | return [ |
||
25 | '_id' => [ |
||
26 | 'unique' => true, |
||
27 | 'default' => function () { |
||
28 | return (new Uuid)->generate(); |
||
29 | }, |
||
30 | 'validator' => [ |
||
31 | 'class' => StringValidator::class, |
||
32 | ] |
||
33 | ], |
||
34 | 'title' => [ |
||
35 | 'unique' => true, |
||
36 | 'required' => true, |
||
37 | 'validator' => [ |
||
38 | 'class' => StringValidator::class, |
||
39 | 'params' => [ |
||
40 | 'maxLength' => 100, |
||
41 | ], |
||
42 | ], |
||
43 | ], |
||
44 | 'status' => [ |
||
45 | 'default' => 0, |
||
46 | 'validator' => [ |
||
47 | 'class' => IntegerValidator::class, |
||
48 | 'params' => [ |
||
49 | 'min' => 0, |
||
50 | 'max' => 1, |
||
60 |