-
Notifications
You must be signed in to change notification settings - Fork 1
/
readme.php
110 lines (85 loc) · 2.16 KB
/
readme.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
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
72
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
108
109
110
<?php
// This file helps with inspection errors in readme.md.
/** @noinspection PhpUnused */
$pdo = new PDO('mysql:host=localhost;charset=utf8mb4;dbname=test', 'username', 'password');
$connection = new Neat\Database\Connection($pdo);
$policy = new Neat\Object\Policy();
$manager = new Neat\Object\Manager($connection, $policy);
$repository = $manager->repository(User::class);
$user = new User();
class User
{
use Neat\Object\Storage;
use Neat\Object\Relations;
/** @var int */
public $id;
/** @var string */
public $name;
/** @var int */
public $alternativeId;
public function greet()
{
echo 'Hello, ' . $this->name . '!';
}
public function address(): Neat\Object\Relations\One
{
return $this->hasOne(Address::class);
}
public function roles(): Neat\Object\Relations\Many
{
return $this->belongsToMany(Role::class);
}
}
class Address
{
}
class Article
{
/** @var string */
public $type;
}
class Role
{
use Neat\Object\Storage;
/** @var string */
public $name;
/** @var bool */
public $invisible;
}
class AgendaLine
{
use Neat\Object\Storage;
/** @var int */
public $id;
/** @var int */
public $appointmentId;
/** @var string */
public $description;
}
class Appointment
{
use Neat\Object\Storage;
use Neat\Object\Relations;
/** @var int */
public $id;
/** @var int */
public $createdBy;
public function creator(): Neat\Object\Relations\One
{
return $this->belongsToOne(User::class, 'creator', function (Neat\Object\Relations\Reference\LocalKeyBuilder $builder) {
// ...
});
}
public function agendaLines(): Neat\Object\Relations\Many
{
return $this->hasMany(AgendaLine::class, 'agenda', function (Neat\Object\Relations\Reference\RemoteKeyBuilder $builder) {
// ...
});
}
public function attendees(): Neat\Object\Relations\Many
{
return $this->belongsToMany(User::class, 'attendees', function (Neat\Object\Relations\Reference\JunctionTableBuilder $builder) {
// ...
});
}
}