1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Tacone\Bees\Test\Customer; |
4
|
|
|
|
5
|
|
|
class Customers |
6
|
|
|
{ |
7
|
|
|
public function anyIndex() |
8
|
|
|
{ |
9
|
|
|
$collection = new EndpointCollection(new Customer()); |
10
|
|
|
$collection->string('name', 'first_name'); |
11
|
|
|
$collection->boolean('published', true); |
12
|
|
|
$collection->dateTime('updated', 'Last update'); |
13
|
|
|
|
14
|
|
|
return $collection; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function anyEdit() |
18
|
|
|
{ |
19
|
|
|
$endpoint = new Endpoint(new Customer()); |
20
|
|
|
$endpoint->string('name', 'first_name'); |
21
|
|
|
$endpoint->boolean('published'); |
22
|
|
|
$endpoint->optional->dateTime('updated', 'Last update'); |
23
|
|
|
|
24
|
|
|
return $endpoint; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function anyOneMethod() |
28
|
|
|
{ |
29
|
|
|
$collection = new Endpoint(new Customer()); |
30
|
|
|
$collection->string('name', 'first_name'); |
31
|
|
|
$collection->boolean('published', true); |
32
|
|
|
$collection->dateTime('updated', 'Last update'); |
33
|
|
|
|
34
|
|
|
$endpoint = new Endpoint(new Customer()); |
35
|
|
|
$endpoint->string('name', 'first_name'); |
36
|
|
|
$endpoint->boolean('published'); |
37
|
|
|
$endpoint->dateTime('updated', 'Last update'); |
38
|
|
|
|
39
|
|
|
return $collection->and($endpoint); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function anyProxy() |
43
|
|
|
{ |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
class UsersController extends ResourceController |
48
|
|
|
{ |
49
|
|
|
public function getResource() |
50
|
|
|
{ |
51
|
|
|
$endpoint = new Endpoint(new Customer()); |
52
|
|
|
$endpoint->string('name', 'first_name'); |
53
|
|
|
$endpoint->boolean('published'); |
54
|
|
|
$endpoint->dateTime('updated', 'Last update'); |
55
|
|
|
|
56
|
|
|
return $endpoint; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function getResourcesCollection() |
60
|
|
|
{ |
61
|
|
|
$collection = new Endpoint(new Customer()); |
62
|
|
|
$collection->string('name', 'first_name'); |
63
|
|
|
$collection->boolean('published', true); |
64
|
|
|
$collection->dateTime('updated', 'Last update'); |
65
|
|
|
|
66
|
|
|
return $collection; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
// add field |
71
|
|
|
$e->string('name', 'user_name', $sortable) |
72
|
|
|
->rules('required|min:4', function ($field) { |
73
|
|
|
return 'custom error string for field '.$field->name(); |
74
|
|
|
}) |
75
|
|
|
->options(['enum', 'of', 'choices']); |
76
|
|
|
|
77
|
|
|
// terminators |
78
|
|
|
$e->errors(); |
79
|
|
|
$e->output($array); |
80
|
|
|
|
81
|
|
|
// field types |
82
|
|
|
$e->string('name'); |
83
|
|
|
$e->integer('age'); |
84
|
|
|
$e->float('age'); |
85
|
|
|
$e->object('location'); |
86
|
|
|
|
87
|
|
|
// field API |
88
|
|
|
$newValue = 1; |
89
|
|
|
$field = f(); |
90
|
|
|
|
91
|
|
|
$field->value(); |
92
|
|
|
$field->value($newValue); |
93
|
|
|
$field->onValue(function () { |
94
|
|
|
}); |
95
|
|
|
$field->onGetValue(function () { |
96
|
|
|
}); |
97
|
|
|
|