-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStandard.php
42 lines (33 loc) · 1.89 KB
/
Standard.php
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
<?php
declare(strict_types=1);
namespace Mvorisek\Atk4\Hintable\Tests\Data\Model;
use Atk4\Data\Model;
/**
* @property string $x @Atk4\Field()
* @property string $y @Atk4\Field(field_name="yy")
* @property string $_name @Atk4\Field(field_name="name") Property Model::name is defined, so we need to use different property name
* @property \DateTimeImmutable $dtImmutable @Atk4\Field()
* @property \DateTimeInterface $dtInterface @Atk4\Field()
* @property \DateTime|\DateTimeImmutable $dtMulti @Atk4\Field()
* @property int $simpleOneId @Atk4\Field()
* @property Simple $simpleOne @Atk4\RefOne()
* @property Simple $simpleMany @Atk4\RefMany()
*/
class Standard extends Model
{
public $table = 'prefix_standard';
#[\Override]
protected function init(): void
{
parent::init();
$this->addField($this->fieldName()->x, ['type' => 'string', 'required' => true]);
$this->addField($this->fieldName()->y, ['type' => 'string', 'required' => true]);
$this->addField($this->fieldName()->_name, ['type' => 'string', 'required' => true]);
$this->addField($this->fieldName()->dtImmutable, ['type' => 'datetime', 'required' => true]);
$this->addField($this->fieldName()->dtInterface, ['type' => 'datetime', 'required' => true]);
$this->addField($this->fieldName()->dtMulti, ['type' => 'datetime', 'required' => true]);
$this->addField($this->fieldName()->simpleOneId, ['type' => 'bigint']);
$this->hasOne($this->fieldName()->simpleOne, ['model' => [Simple::class], 'ourField' => $this->fieldName()->simpleOneId]);
$this->hasMany($this->fieldName()->simpleMany, ['model' => [Simple::class], 'theirField' => Simple::hinting()->fieldName()->refId]);
}
}